Part Number Hot Search : 
477M00 C450PD2 GP1U27R 4AC15 WM71004 OV9655 SFH221 IRLU3802
Product Description
Full Text Search
 

To Download H8S2149F-ZTAT Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  regarding the change of names mentioned in the document, such as hitachi electric and hitachi xx, to renesas technology corp. the semiconductor operations of mitsubishi electric and hitachi were transferred to renesas technology corporation on april 1st 2003. these operations include microcomputer, logic, analog and discrete devices, and memory chips other than drams (flash memory, srams etc.) accordingly, although hitachi, hitachi, ltd., hitachi semiconductors, and other hitachi brand names are mentioned in the document, these names have in fact all been changed to renesas technology corp. thank you for your understanding. except for our corporate trademark, logo and corporate statement, no changes whatsoever have been made to the contents of the document, and these changes do not constitute any alteration to the contents of the document itself. renesas technology home page: http://www.renesas.com renesas technology corp. customer support dept. april 1, 2003 to all our customers
cautions keep safety first in your circuit designs! 1. renesas technology corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. trouble with semiconductors may lead to personal injury, fire or property damage. remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap. notes regarding these materials 1. these materials are intended as a reference to assist our customers in the selection of the renesas technology corporation product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to renesas technology corporation or a third party. 2. renesas technology corporation assumes no responsibility for any damage, or infringement of any third-party's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in these materials. 3. all information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of these materials, and are subject to change by renesas technology corporation without notice due to product improvements or other reasons. it is therefore recommended that customers contact renesas technology corporation or an authorized renesas technology corporation product distributor for the latest product information before purchasing a product listed herein. the information described here may contain technical inaccuracies or typographical errors. renesas technology corporation assumes no responsibility for any damage, liability, or other loss rising from these inaccuracies or errors. please also pay attention to information published by renesas technology corporation by various means, including the renesas technology corporation semiconductor home page (http://www.renesas.com). 4. when using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products. renesas technology corporation assumes no responsibility for any damage, liability or other loss resulting from the information contained herein. 5. renesas technology corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake. please contact renesas technology corporation or an authorized renesas technology corporation product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. 6. the prior written approval of renesas technology corporation is n ecessary to reprint or reproduce in whole or in part these materials. 7. if these products or technologies are subject to the japanese export control restrictions, they must be exported under a license from the japanese government and cannot be imported into a country other than the approved destination. any diversion or reexport contrary to the export control laws and regulations of japan and/or the country of destination is prohibited. 8. please contact renesas technology corporation for further details on these materials or the products contained therein.
hitachi 16-bit single-chip microcomputer h8s/2169f-ztat h8s/2149f-ztat h8s/2169 hd64f2169 h8s/2149 hd64f2149 hardware manual ade-602-190a rev. 2.0 02/21/01 hitachi, ltd.
cautions 1. hitachi neither warrants nor grants licenses of any rights of hitachi? or any third party? patent, copyright, trademark, or other intellectual property rights for information contained in this document. hitachi bears no responsibility for problems that may arise with third party? rights, including intellectual property rights, in connection with use of the information contained in this document. 2. products and product specifications may be subject to change without notice. confirm that you have received the latest product standards or specifications before final design, purchase or use. 3. hitachi makes every attempt to ensure that its products are of high quality and reliability. however, contact hitachi? sales office before using the product in an application that demands especially high quality and reliability or where its failure or malfunction may directly threaten human life or cause risk of bodily injury, such as aerospace, aeronautics, nuclear power, combustion control, transportation, traffic, safety equipment or medical equipment for life support. 4. design your application so that the product is used within the ranges guaranteed by hitachi particularly for maximum rating, operating supply voltage range, heat radiation characteristics, installation conditions and other characteristics. hitachi bears no responsibility for failure or damage when used beyond the guaranteed ranges. even within the guaranteed ranges, consider normally foreseeable failure rates or failure modes in semiconductor devices and employ systemic measures such as fail-safes, so that the equipment incorporating hitachi product does not cause bodily injury, fire or other consequential damage due to operation of the hitachi product. 5. this product is not designed to be radiation resistant. 6. no one is permitted to reproduce or duplicate, in any form, the whole or part of this document without written approval from hitachi. 7. contact hitachi? sales office for any questions regarding this document or hitachi semiconductor products.
preface the h8s/2149 and h8s/2169 f-ztat comprises high-performance microcomputers with a 32- bit h8s/2000 cpu core, and a set of on-chip supporting functions required for system configuration. the h8s/2000 cpu can execute basic instructions in one state, and is provided with sixteen internal 16-bit general registers with a 32-bit configuration, and a concise and optimized instruction set. the cpu can handle a 16-mbyte linear address space (architecturally 4 gbytes). programs based on the high-level language c can also be run efficiently. single-power-supply flash memory (f-ztat*) is available, providing a quick and flexible response to conditions from ramp-up through full-scale volume production, even for applications with frequently changing specifications. on-chip peripheral functions include a 16-bit free-running timer (frt), 8-bit timer (tmr), watchdog timer (wdt), two pwm timers (pwm and pwmx), a serial communication interface (sci, irda), i 2 c bus interface (iic), ps/2-compatible keyboard buffer controller, host interface (hif:xbs and lpc), d/a converter (dac), a/d converter (adc), and i/o ports. an on-chip data transfer controller (dtc) is also provided, enabling high-speed data transfer without cpu intervention. use of the h8s/2149 and h8s/2169 f-ztat enables compact, high-performance systems to be implemented easily. the comprehensive pc-related interface functions and 16 8 matrix key- scan functions are ideal for applications such as notebook pc keyboard control and intelligent battery and power supply control. in particular, the provision of two on-chip host interfaces? conventional x-bus (isa) interface and an lpc interface (a new standard)?rovide flexible support for pc systems in a period of transition. this manual describes the hardware of the h8s/2149 and h8s/2169 f-ztat. refer to the h8s/2600 series and h8s/2000 series programming manual for a detailed description of the instruction set. this manual describes the hardware of the h8s/2149 and h8s/2169 f-ztat. although the h8s/2169 is not explicitly mentioned in section 2 to 7 or section 9 to 22, the descriptions in these sections apply to both the h8s/2149 and h8s/2169. note: * f-ztat (flexible-ztat) is a trademark of hitachi, ltd.

main revisions and additions in this edition page item revision (see manual for details) all pages of this manual amendments due to introduction of the h8s/2169 2 to 6 1. overview table 1.1 overview cpu: operating frequency, and arithmetic operations amended pwm: maximum carrier frequency amended pwmx: maximum carrier frequency amended a/d converter: minimum conversion time amended i/o ports: h8s/2169 added packages: tfp-144 (h8s/2169) added product lineup: amended 8 1.2 internal block diagram figure 1.1(b) internal block diagram of h8s/2169 added 10 1.3.1 pin arrangement figure 1.2(b) h8s/2169 pin arrangement added 11 1.3.2 pin functions in each operating mode table 1.2(a) h8s/2149 pin functions in each operating mode pin no.9 : pin function of flash memory programmer mode amended 16 to 21 1.3.2 pin functions in each operating mode table 1.2(b) h8s/2169 pin functions in each operating mode 22 to 30 1.3.3 pin functions table 1.3 pin functions power (vcl), (vccb) description amended clock (x1), (x2) description amended ports c to g description added tfp-144 pin function added all pages of section 2 notes on tas instruction added notes on stm/ldm instruction added 32 2.1.1 features high-speed operation amended 73 2.9.4 on-chip supporting module access timing (internal i/o register 3) added 78 3.2.2 system control register address amended when bits 6 is 1 79 3.2.3 bus control register address amended when bits 1 and 0 are 1, respectively 83 3.4 pin function in each operating mode table 3.3 pin functions in each mode ports c to g added 84, 85 3.5 memory map in each operating mode figure 3.1 h8s/2169 or h8s/2149 memory map in each operating mode amended
page item revision (see manual for details) 89 4.1.3 exception source and vector table table 4.2 exception vector table internal interrupt address amended 98 5.1.2 block diagram figure 5.1 block diagram of interrupt controller names of internal interrupt request amended 102 5.2.2 interrupt control registers a to c description amended (address break) 105 5.2.5 irq status register bits 7 to 0: note added 105, 106 5.2.6 keyboard matrix interrupt mask register description and note amended 112 5.3.1 external interrupt description on irq6 pin added 114 5.3.3 interrupt sources, vector addresses, and interrupt priorities interrupt source name amended (address break (pc break)) 119 5.5.1 interrupt control modes and interrupt operation description amended (address break) 120 table 5.6 interrupt selected in each interrupt control mode description amended (address break) 122 5.5.2 interrupt control mode 0 description amended (address break) 123 figure 5.8 flowchart of procedure up to interrupt acceptance in interrupt control mode 0 interrupt name amended (ibfi3) 124, 125 5.5.3 interrupt control mode 1 description amended (address break) 126 figure 5.10 flowchart of procedure up to interrupt acceptance in interrupt control mode 1 interrupt name amended (ibfi3) 129 5.5.5 interrupt response times table 5.8 interrupt response times number of wait states until execution instruction ends amended 139 6.2.2.wait state control register bits 7 and 6 description amended 143 6.3.4 i/o select signal table 6.4 ios signal output range settings address amended when ios1 and ios0 are 1, respectively 155 6.4.5 wait control figure 6.13 example of wait state insertion timing hwr, lwr timing amended
page item revision (see manual for details) 189 8.1 overview amendments due to introduction of the h8s/2169 description added 253, 254 8.12.3 pin functions table 8.24 port b pin functions pb1 and pb0 : table amended 255 to 256 8.13 additional overview for h8s/2169 added 256 to 261 8.14 ports c, d added 261 to 265 8.15 ports e, f added 266 to 269 8.16 port g added 271 9.1.1 features carrier frequency amended 273 9.1.4 register configuration table 9.2 pwm timer module registers note 2 added 275 9.2.1 pwm register select table 9.3 resolution, pwm conversion period, and carrier frequency when f = 10 mhz completely amended due to changes of the system clock 285 10.1.4 register configuration table 10.2 register configuration note 2 amended 287 10.2.2 d/a data registers a and b address amended when bit 1 is 1 326 11.6 usage notes figure 11.21 contention between ocrar/ocraf write and compare-match added 342 12.2.6 serial/timer control register bit 3: description amended 352 to 354 12.3.6 input capture operation added 377 13.3.1 pwm decoding table 13.4 examples of tcorb settings f = 12 mhz or more deleted figure 13.2 timing chart for pwm decoding ihi signal amended 379 13.3.3 measurement of 8- bit timer divided waveform period external reset signal description amended 396, 398, 399 14.2.2 timer control/status register bit 7: note added bits 2 to 0: overflow period amended 406 to 407 14.5.6 ovf flag clear condition added 410 15.1.1 features capability of transmit and receive clock output added
page item revision (see manual for details) 428 to 432 15.2.8 bit rate register note added table 15.3 brr settings for various bit rates f = 12 mhz or more deleted table 15.4 brr settings for various bit rates f = 16 mhz or more deleted table 15.5 maximum bit rate for each frequency f = 12 mhz or more deleted table 15.6 maximum bit rate with external clock input f = 12 mhz or more deleted table 15.7 maximum bit rate with external clock input f = 12 mhz or more deleted 449 15.3.2 operation in asynchronous mode figure 15.8 example of sci operation in reception amended (stop bit) 15.3.3 multiprocessor communication function figure 15.10 sample multiprocessor serial transmission flowchart amended 469 15.3.5 irda operation table 15.12 bit ircks2 to ircks0 settings f = 12 mhz or more deleted 482 16.2.1 i 2 c bus data register tdre flag: description amended when tdre is 1 487 16.2.4 i 2 c bus mode register bits 5 to 3: transfer rate f = 16 mhz or more deleted 489, 493 16.2.5 i 2 c bus control register bits 7: description amended when ice is 0 bits 1: description amended when iric is 1 499 16.2.6 i 2 c bus status register bit 0: description added "when writing to this bit, ...bit-manipulation instructions." 501 16.2.7 serial/timer control register bit 3: description amended 505 16.3.1 i 2 c bus data format figure 16.4 formatless added 506 to 508 16.3.2 master transmit operation completely amended 508 to 510 16.3.3 master receive operation completely amended 517 16.3.7 automatic switching from formatless mode to i 2 c bus format description on preconditions amended (formatless operation)
page item revision (see manual for details) 520 16.3.10 sample flowcharts figure 16.14 flowchart for master transmit mode completely amended 521 figure 16.15 flowchart for master receive mode completely amended 523, 524 16.3.11 initialization of internal state notes on initialization: description amended 526 16.4 usage notes table 16.7 permissible scl rise time values f = 16 mhz or more deleted 527 table16.8 i 2 c bus timing f = 16 mhz or more deleted 529, 530 notes on start condition issuance for retransmission notes on i 2 c bus interface stop condition instruction issuance added 538 17.2.4 module stop control register added 557 18a.2.1 system control register bit 1: description amended 572 18a.5 usage note (2) data contention on the host interface data bus (hdb) added 587 18b.2.3 host interface control registers 2 and 3 hicr2 bits 3 to 0: description amended when ibfie3 is set to 1 589 18b.2.4 lpc channel 3 address register ladr3l bit 2: description amended 596 to 603 18b.2.9 serirq control registers names of serirq interrupt sources amended 610 18b.3.4 host interface shutdown function table 18b.5 scope of hif pin shutdown clkrun i/o amended note added 616 18b.4.1 ibf1, ibf2, ibf3, erri table 18b.7 receive complete interrupts are error interrupt ibf3 description amended 618, 619 18b.5 usage note (3) added 627 20.1.1 features conversion time amended 634 20.2.3 a/d control register bits 5 to 0: description amended 645 20.6 usage notes table 20.5 analog pin ratings permissible signal source impedance max. value amended note added
page item revision (see manual for details) 649 20.6 usage notes permissible signal source impedance: impedance value amended 651 21.1.1 block diagram figure 21.1 block diagram of ram address amended 653 21.3.1 example mode address amended when the rame bit is cleared to 0 21.3.2 single-chip mode description amended 658 22.4.1 features programming/erase times: amended 660 22.4.3 flash memory operating modes figure 22.3 flash memory mode transitions bit name amended (user mode ? user program mode) 667 22.5.2 flash memory control register 2 bits 6 to 2: description amended 672 22.6.1 boot mode figure 22.8 boot mode execution procedure amended 673 table 22.8 system clock frequencies for which automatic adjustment of the chip bit rate is possible system clock frequency amended 673, 674 on-chip ram area divisions in boot mode: description amended figure 22.10 ram areas in boot mode amended 685 22.10.1 programmer mode setting note added 696 22.11 flash memory programming and erasing precautions description for prom programmer amended 702 23.3.1 connecting a crystal resonator table 23.2 damping resistance value f = 12 mhz or more deleted table 23.3 crystal resonator parameters f = 12 mhz or more deleted 704 23.3.2 external clock input table 23.4 external clock input conditions vcc range amended 705 table 23.5 external clock output setting delay time conditions amended 706 23.7 subclock input circuit table 23.6 subclock input conditions vcc range amended 707 23.9 clock selection circuit added
page item revision (see manual for details) 708 23.10 x1 and x2 pins added 710 24.1 overview table 24.1 the chip's internal states in each mode hif: lpc added i/o: state amended in subsleep mode 713 24.1.1 register configuration table 24.3 power-down state registers note 2 added 717 24.2.2 low-power control register bits 3, 2 to 0 description amended 722 24.5.1 module stop mode table 24.4 mstp bits and corresponding on-chip supporting modules mstp2 bit module amended 724 24.6.3 setting occillation setting time after clearing software standby mode table 24.5 oscillation setting time settings f = 12 mhz or more deleted note amended 733 25.1 absolute maximum ratings table 25.1 absolute maximum ratings value amended note added 734 to 739 25.2 dc characteristics completely amended 741 25.3.1 clock timing table 25.5 clock timing amendment due to condition change 743 25.3.2 control signal timing table 25.6 control signal timing amendment due to condition change 745 25.3.3 bus timing table 25.7 bus timing amendment due to condition change 752, 756 25.3.4 timing of on-chip supporting modules table 25.8 timing of on-chip supporting modules amendment due to condition change 758 table 25.9 keyboard buffer controller timing amendment due to condition change 759 table 25.10 i 2 c bus timing amendment due to condition change 760 table 25.11 lpc module timing amendment due to condition change 761 figure 25.28 host interface(lpc) timing lclk timing amended
page item revision (see manual for details) 762, 763 25.4 a/d conversion characteristics table 25.12 and table 25.13 a/d conversion characteristics amendment due to condition change permissible, signal-source impedance value amended 763 25.5 d/a conversion characteristics table 25.14 d/a conversion characteristics amendment due to condition change 764, 765 25.6 flash memory characteristics table25.15 flash memory characteristics amendment due to condition change notes 4 and 5 amended 766 25.7 usage note completely amended all pages of appendix a note on tas instruction added note on stm/ldm instruction added 841 to 850 b.2 amendments due to introduction of the h8s/2169
page item revision (see manual for details) - b.3 functions registers amended h?e35: ladr3l h?e36, h?e37: sirqcr0, sirqcr1 h?e42: hicr2 h?e80: hicr2 h?eeb: isr h?f82, h?f83: ebr1, ebr2 h?f87: mstpcrl h?f88, h?fd8: iccr1, iccr0 h?f8f, h?fdf: icmr1, icmr0 h?fc4, syscr h?fc6, bcr h?e16: pgnocr h?e18: penocr h?e19: pfnocr h?e1c: pcnocr h?e1d: pdnocr h?e46: pgodr h?e47(r): pgpin h?e47(w): pgddr h?e48: peodr h?e49: pfodr h?e4a(r): pepin h?e4a(w): peddr h?e4b(r): pfpin h?e4b(w): pfddr h?e4c: pcodr h?e4d: pdodr h?e4e(r): pcpin h?e4e(w): pcddr h?e4f(r): pdpin h?e4f(w): pdddr 951 c. i/o port block diagrams figure c.2 port 2 block diagram (pins p20 to p23) amended 952 figure c.3 port 2 block diagram (pins p24 to p26) amended 953 figure c.4 port 2 block diagram (pin p27) amended
page item revision (see manual for details) 959 c. i/o port block diagrams figure c.10 port 4 block diagram (pin p42) amended 966 figure c.17 port 5 block diagram (pin p52) amended 973 figure c.25 port 8 block diagram (pin p80) amended 979 figure c.31 port 8 block diagram (pin p86) amended 980 figure c.32 port 9 block diagram (pin p90) amended 982 figure c.34 port 9 block diagram (pins p93 to p95) amended 984 figure c.36 port 9 block diagram (pin p97) amended 985 figure c.37 port a block diagram (pins pa0, pa1) amended 986 figure c.38 port a block diagram (pins pa2, pa3) amended 987 figure c.39 port a block diagram (pins pa4 to pa7) amended 989 figure c.41 port b block diagram (pins pb2, pb3) amended 991 figure c.43 ports c, d, e, f, g block diagram amended 993 d.1 port states in each processing state table d.1 i/o port states in each processing state ports c to g added 995 f. product code lineup table f.1 product codes amended 998 g. package dimensions figure g.3 package dimensions(tfp-144) added
i contents section 1 overview ........................................................................................................... 1 1.1 overview................................................................................................................... ......... 1 1.2 block diagram.............................................................................................................. ..... 7 1.3 pin arrangement and functions ........................................................................................ 9 1.3.1 pin arrangement .................................................................................................. 9 1.3.2 pin functions in each operating mode................................................................ 11 1.3.3 pin functions........................................................................................................ 22 section 2 cpu ..................................................................................................................... 31 2.1 overview................................................................................................................... ......... 31 2.1.1 features................................................................................................................. 31 2.1.2 differences between h8s/2600 cpu and h8s/2000 cpu .................................. 32 2.1.3 differences from h8/300 cpu............................................................................. 33 2.1.4 differences from h8/300h cpu.......................................................................... 33 2.2 cpu operating modes ...................................................................................................... 34 2.3 address space.............................................................................................................. ...... 39 2.4 register configuration ..................................................................................................... .40 2.4.1 overview .............................................................................................................. 40 2.4.2 general registers.................................................................................................. 41 2.4.3 control registers.................................................................................................. 42 2.4.4 initial register values .......................................................................................... 43 2.5 data formats............................................................................................................... ....... 44 2.5.1 general register data formats ............................................................................ 44 2.5.2 memory data formats.......................................................................................... 46 2.6 instruction set............................................................................................................ ........ 47 2.6.1 overview .............................................................................................................. 47 2.6.2 instructions and addressing modes ..................................................................... 48 2.6.3 table of instructions classified by function........................................................ 50 2.6.4 basic instruction formats..................................................................................... 57 2.6.5 notes on use of bit-manipulation instructions.................................................... 58 2.7 addressing modes and effective address calculation ..................................................... 58 2.7.1 addressing mode.................................................................................................. 58 2.7.2 effective address calculation.............................................................................. 61 2.8 processing states .......................................................................................................... ..... 65 2.8.1 overview .............................................................................................................. 65 2.8.2 reset state ............................................................................................................ 66 2.8.3 exception-handling state .................................................................................... 67 2.8.4 program execution state ...................................................................................... 68 2.8.5 bus-released state ............................................................................................... 68
ii 2.8.6 power-down state................................................................................................ 68 2.9 basic timing............................................................................................................... ....... 69 2.9.1 overview .............................................................................................................. 69 2.9.2 on-chip memory (rom, ram) ......................................................................... 69 2.9.3 on-chip supporting module access timing (internal i/o register 1 and 2) ..... 71 2.9.4 on-chip supporting module access timing (interna i/o register 3) ................ 73 2.9.5 external address space access timing............................................................... 74 2.10 usage note ................................................................................................................. ....... 74 2.10.1 tas instruction .................................................................................................... 74 2.10.2 stm/ldm instruction.......................................................................................... 74 section 3 mcu operating modes ................................................................................ 75 3.1 overview................................................................................................................... ......... 75 3.1.1 operating mode selection.................................................................................... 75 3.1.2 register configuration ......................................................................................... 76 3.2 register descriptions...................................................................................................... ... 76 3.2.1 mode control register (mdcr).......................................................................... 76 3.2.2 system control register (syscr) ...................................................................... 77 3.2.3 bus control register (bcr) ................................................................................ 79 3.2.4 serial timer control register (stcr)................................................................. 80 3.3 operating mode descriptions............................................................................................ 82 3.3.1 mode 1.................................................................................................................. 8 2 3.3.2 mode 2.................................................................................................................. 8 2 3.3.3 mode 3.................................................................................................................. 8 2 3.4 pin functions in each operating mode............................................................................. 83 3.5 memory map in each operating mode............................................................................. 83 section 4 exception handling ........................................................................................ 87 4.1 overview................................................................................................................... ......... 87 4.1.1 exception handling types and priority ............................................................... 87 4.1.2 exception handling operation ............................................................................. 88 4.1.3 exception sources and vector table.................................................................... 88 4.2 reset ...................................................................................................................... ............ 90 4.2.1 overview .............................................................................................................. 90 4.2.2 reset sequence..................................................................................................... 90 4.2.3 interrupts after reset ............................................................................................ 92 4.3 interrupts................................................................................................................. ........... 93 4.4 trap instruction ........................................................................................................... ...... 94 4.5 stack status after exception handling .............................................................................. 95 4.6 notes on use of the stack.................................................................................................. 96 section 5 interrupt controller ........................................................................................ 97 5.1 overview................................................................................................................... ......... 97
iii 5.1.1 features ................................................................................................................ 9 7 5.1.2 block diagram...................................................................................................... 98 5.1.3 pin configuration ................................................................................................. 99 5.1.4 register configuration ......................................................................................... 100 5.2 register descriptions...................................................................................................... ... 101 5.2.1 system control register (syscr) ...................................................................... 101 5.2.2 interrupt control registers a to c (icra to icrc)............................................ 102 5.2.3 irq enable register (ier) .................................................................................. 103 5.2.4 irq sense control registers h and l (iscrh, iscrl)..................................... 103 5.2.5 irq status register (isr) .................................................................................... 104 5.2.6 keyboard matrix interrupt mask register (kmimr).......................................... 105 5.2.7 keyboard matrix interrupt mask register a (kmimra) wakeup event interrupt mask registr b (wuemrb) ................................................................ 106 5.2.8 address break control register (abrkcr)....................................................... 109 5.2.9 break address registers a, b, c (bara, barb, barc)................................. 110 5.3 interrupt sources.......................................................................................................... ...... 111 5.3.1 external interrupts................................................................................................ 111 5.3.2 internal interrupts ................................................................................................. 113 5.3.3 interrupt exception vector table......................................................................... 113 5.4 address breaks............................................................................................................. ..... 116 5.4.1 features ................................................................................................................ 1 16 5.4.2 block diagram...................................................................................................... 116 5.4.3 operation .............................................................................................................. 11 7 5.4.4 usage notes.......................................................................................................... 117 5.5 interrupt operation ........................................................................................................ .... 119 5.5.1 interrupt control modes and interrupt operation ................................................ 119 5.5.2 interrupt control mode 0...................................................................................... 122 5.5.3 interrupt control mode 1...................................................................................... 124 5.5.4 interrupt exception handling sequence .............................................................. 127 5.5.5 interrupt response times..................................................................................... 129 5.6 usage notes ................................................................................................................ ....... 130 5.6.1 contention between interrupt generation and disabling..................................... 130 5.6.2 instructions that disable interrupts ...................................................................... 131 5.6.3 interrupts during execution of eepmov instruction.......................................... 131 5.7 dtc activation by interrupt ............................................................................................. 132 5.7.1 overview .............................................................................................................. 132 5.7.2 block diagram...................................................................................................... 132 5.7.3 operation .............................................................................................................. 13 3 section 6 bus controller .................................................................................................. 135 6.1 overview................................................................................................................... ......... 135 6.1.1 features ................................................................................................................ 1 35 6.1.2 block diagram...................................................................................................... 136
iv 6.1.3 pin configuration ................................................................................................. 137 6.1.4 register configuration ......................................................................................... 137 6.2 register descriptions...................................................................................................... ... 138 6.2.1 bus control register (bcr) ................................................................................ 138 6.2.2 wait state control register (wscr)................................................................... 139 6.3 overview of bus control................................................................................................... 1 41 6.3.1 bus specifications ................................................................................................ 141 6.3.2 advanced mode.................................................................................................... 142 6.3.3 normal mode........................................................................................................ 142 6.3.4 i/o select signal................................................................................................... 142 6.4 basic bus interface........................................................................................................ .... 143 6.4.1 overview .............................................................................................................. 143 6.4.2 data size and data alignment ............................................................................. 143 6.4.3 valid strobes ........................................................................................................ 145 6.4.4 basic timing ........................................................................................................ 146 6.4.5 wait control ......................................................................................................... 154 6.5 burst rom interface ........................................................................................................ . 156 6.5.1 overview .............................................................................................................. 156 6.5.2 basic timing ........................................................................................................ 156 6.5.3 wait control ......................................................................................................... 157 6.6 idle cycle................................................................................................................. .......... 158 6.6.1 operation .............................................................................................................. 15 8 6.6.2 pin states in idle cycle ........................................................................................ 159 6.7 bus arbitration ............................................................................................................ ...... 159 6.7.1 overview .............................................................................................................. 159 6.7.2 operation .............................................................................................................. 15 9 6.7.3 bus transfer timing ............................................................................................ 160 section 7 data transfer controller .............................................................................. 161 7.1 overview................................................................................................................... ......... 161 7.1.1 features ................................................................................................................ 1 61 7.1.2 block diagram...................................................................................................... 162 7.1.3 register configuration ......................................................................................... 163 7.2 register descriptions...................................................................................................... ... 164 7.2.1 dtc mode register a (mra)............................................................................. 164 7.2.2 dtc mode register b (mrb) ............................................................................. 166 7.2.3 dtc source address register (sar) .................................................................. 167 7.2.4 dtc destination address register (dar) .......................................................... 167 7.2.5 dtc transfer count register a (cra) .............................................................. 167 7.2.6 dtc transfer count register b (crb) ............................................................... 168 7.2.7 dtc enable registers (dtcer) ......................................................................... 168 7.2.8 dtc vector register (dtvecr) ........................................................................ 169 7.2.9 module stop control register (mstpcr) .......................................................... 170
v 7.3 operation .................................................................................................................. ......... 171 7.3.1 overview .............................................................................................................. 171 7.3.2 activation sources................................................................................................ 173 7.3.3 dtc vector table ................................................................................................ 174 7.3.4 location of register information in address space ............................................ 176 7.3.5 normal mode........................................................................................................ 177 7.3.6 repeat mode ........................................................................................................ 178 7.3.7 block transfer mode............................................................................................ 179 7.3.8 chain transfer...................................................................................................... 181 7.3.9 operation timing ................................................................................................. 182 7.3.10 number of dtc execution states........................................................................ 183 7.3.11 procedures for using the dtc ............................................................................. 185 7.3.12 examples of use of the dtc................................................................................ 186 7.4 interrupts................................................................................................................. ........... 188 7.5 usage notes ................................................................................................................ ....... 188 section 8 i/o ports ............................................................................................................ 189 8.1 overview................................................................................................................... ......... 189 8.2 port 1..................................................................................................................... ............. 195 8.2.1 overview .............................................................................................................. 195 8.2.2 register configuration ......................................................................................... 196 8.2.3 pin functions in each mode ................................................................................ 198 8.2.4 mos input pull-up function ............................................................................... 199 8.3 port 2..................................................................................................................... ............. 200 8.3.1 overview .............................................................................................................. 200 8.3.2 register configuration ......................................................................................... 202 8.3.3 pin functions in each mode ................................................................................ 204 8.3.4 mos input pull-up function ............................................................................... 205 8.4 port 3..................................................................................................................... ............. 207 8.4.1 overview ................................................................................................................. . 207 8.4.2 register configuration ......................................................................................... 208 8.4.3 pin functions in each mode ................................................................................ 210 8.4.4 mos input pull-up function ............................................................................... 211 8.5 port 4..................................................................................................................... ............. 212 8.5.1 overview .............................................................................................................. 212 8.5.2 register configuration ......................................................................................... 212 8.5.3 pin functions........................................................................................................ 213 8.6 port 5..................................................................................................................... ............. 217 8.6.1 overview .............................................................................................................. 217 8.6.2 register configuration ......................................................................................... 217 8.6.3 pin functions........................................................................................................ 219 8.7 port 6..................................................................................................................... ............. 220 8.7.1 overview .............................................................................................................. 220
vi 8.7.2 register configuration ......................................................................................... 221 8.7.3 pin functions........................................................................................................ 224 8.7.4 mos input pull-up function ............................................................................... 226 8.8 port 7..................................................................................................................... ............. 227 8.8.1 overview .............................................................................................................. 227 8.8.2 register configuration ......................................................................................... 227 8.8.3 pin functions........................................................................................................ 228 8.9 port 8..................................................................................................................... ............. 229 8.9.1 overview .............................................................................................................. 229 8.9.2 register configuration ......................................................................................... 229 8.9.3 pin functions........................................................................................................ 230 8.10 port 9.................................................................................................................... .............. 234 8.10.1 overview .............................................................................................................. 23 4 8.10.2 register configuration ......................................................................................... 235 8.10.3 pin functions........................................................................................................ 236 8.11 port a.................................................................................................................... ............. 240 8.11.1 overview .............................................................................................................. 24 0 8.11.2 register configuration ......................................................................................... 241 8.11.3 pin functions........................................................................................................ 242 8.11.4 mos input pull-up function ............................................................................... 246 8.12 port b .................................................................................................................... ............. 247 8.12.1 overview .............................................................................................................. 24 7 8.12.2 register configuration ......................................................................................... 248 8.12.3 pin functions........................................................................................................ 250 8.12.4 mos input pull-up function ............................................................................... 255 8.13 additional overview for h8s/2169 .................................................................................. 255 8.14 ports c, d ................................................................................................................. ......... 256 8.14.1 overview .............................................................................................................. 256 8.14.2 register configuration ......................................................................................... 257 8.14.3 pin functions........................................................................................................ 260 8.14.4 mos input pull-up function ............................................................................... 260 8.15 ports e, f ................................................................................................................. .......... 261 8.15.1 overview .............................................................................................................. 261 8.15.2 register configuration ......................................................................................... 262 8.15.3 pin functions........................................................................................................ 265 8.15.4 mos input pull-up function ............................................................................... 265 8.16 port g..................................................................................................................... ............ 266 8.16.1 overview .............................................................................................................. 266 8.16.2 register configuration ......................................................................................... 266 8.16.3 pin functions........................................................................................................ 268 8.16.4 mos input pull-up function ............................................................................... 268 section 9 8-bit pwm timers ......................................................................................... 271
vii 9.1 overview................................................................................................................... ......... 271 9.1.1 features ................................................................................................................ 2 71 9.1.2 block diagram...................................................................................................... 272 9.1.3 pin configuration ................................................................................................. 273 9.1.4 register configuration ......................................................................................... 273 9.2 register descriptions...................................................................................................... ... 274 9.2.1 pwm register select (pwsl) ............................................................................. 274 9.2.2 pwm data registers (pwdr0 to pwdr15) ...................................................... 276 9.2.3 pwm data polarity registers a and b (pwdpra and pwdprb).................... 276 9.2.4 pwm output enable registers a and b (pwoera and pwoerb) ................. 277 9.2.5 peripheral clock select register (pcsr) ............................................................ 278 9.2.6 port 1 data direction register (p1ddr) ............................................................. 278 9.2.7 port 2 data direction register (p2ddr) ............................................................. 279 9.2.8 port 1 data register (p1dr) ................................................................................ 279 9.2.9 port 2 data register (p2dr) ................................................................................ 279 9.2.10 module stop control register (mstpcr) .......................................................... 280 9.3 operation .................................................................................................................. ......... 281 9.3.1 correspondence between pwm data register contents and output waveform 281 section 10 14-bit pwm timer ........................................................................................ 283 10.1 overview.................................................................................................................. .......... 283 10.1.1 features ................................................................................................................ 283 10.1.2 block diagram...................................................................................................... 284 10.1.3 pin configuration ................................................................................................. 284 10.1.4 register configuration ......................................................................................... 285 10.2 register descriptions..................................................................................................... .... 285 10.2.1 pwm (d/a) counter (dacnt) .......................................................................... 285 10.2.2 d/a data registers a and b (dadra and dadrb)......................................... 286 10.2.3 pwm (d/a) control register (dacr)................................................................ 287 10.2.4 module stop control register (mstpcr) .......................................................... 289 10.3 bus master interface...................................................................................................... .... 290 10.4 operation ................................................................................................................. .......... 293 section 11 16-bit free-running timer ......................................................................... 297 11.1 overview.................................................................................................................. .......... 297 11.1.1 features ................................................................................................................ 297 11.1.2 block diagram...................................................................................................... 298 11.1.3 input and output pins........................................................................................... 299 11.1.4 register configuration ......................................................................................... 300 11.2 register descriptions..................................................................................................... .... 301 11.2.1 free-running counter (frc)............................................................................... 301 11.2.2 output compare registers a and b (ocra, ocrb) ......................................... 301 11.2.3 input capture registers a to d (icra to icrd) ................................................ 302
viii 11.2.4 output compare registers ar and af (ocrar, ocraf) ............................... 303 11.2.5 output compare register dm (ocrdm) ........................................................... 304 11.2.6 timer interrupt enable register (tier) .............................................................. 304 11.2.7 timer control/status register (tcsr) ................................................................ 306 11.2.8 timer control register (tcr) ............................................................................. 309 11.2.9 timer output compare control register (tocr) .............................................. 311 11.2.10 module stop control register (mstpcr) .......................................................... 313 11.3 operation ................................................................................................................. .......... 314 11.3.1 frc increment timing ........................................................................................ 314 11.3.2 output compare output timing .......................................................................... 315 11.3.3 frc clear timing................................................................................................ 316 11.3.4 input capture input timing.................................................................................. 316 11.3.5 timing of input capture flag (icf) setting ........................................................ 318 11.3.6 setting of output compare flags a and b (ocfa, ocfb)................................ 319 11.3.7 setting of frc overflow flag (ovf).................................................................. 320 11.3.8 automatic addition of ocra and ocrar/ocraf.......................................... 320 11.3.9 icrd and ocrdm mask signal generation ...................................................... 321 11.4 interrupts................................................................................................................ ............ 322 11.5 sample application ........................................................................................................ ... 322 11.6 usage notes ............................................................................................................... ........ 323 section 12 8-bit timers ..................................................................................................... 329 12.1 overview.................................................................................................................. .......... 329 12.1.1 features ................................................................................................................ 329 12.1.2 block diagram...................................................................................................... 330 12.1.3 pin configuration ................................................................................................. 331 12.1.4 register configuration ......................................................................................... 332 12.2 register descriptions..................................................................................................... .... 333 12.2.1 timer counter (tcnt) ........................................................................................ 333 12.2.2 time constant register a (tcora) ................................................................... 334 12.2.3 time constant register b (tcorb) ................................................................... 335 12.2.4 timer control register (tcr) ............................................................................. 335 12.2.5 timer control/status register (tcsr) ................................................................ 339 12.2.6 serial/timer control register (stcr) ................................................................ 342 12.2.7 system control register (syscr) ...................................................................... 343 12.2.8 timer connection register s (tconrs)............................................................ 343 12.2.9 input capture register (ticr) [tmrx additional function] ............................ 344 12.2.10 time constant register c (tcorc) [tmrx additional function]................... 344 12.2.11 input capture registers r and f (ticrr, ticrf) [tmrx additional functions] ............................................................................. 345 12.2.12 timer input select register (tisr) [tmry additional function]..................... 345 12.2.13 module stop control register (mstpcr) .......................................................... 346 12.3 operation ................................................................................................................. .......... 347
ix 12.3.1 tcnt incrementation timing.............................................................................. 347 12.3.2 compare-match timing ....................................................................................... 348 12.3.3 tcnt external reset timing .............................................................................. 350 12.3.4 timing of overflow flag (ovf) setting.............................................................. 350 12.3.5 operation with cascaded connection .................................................................. 351 12.3.6 input capture operation ....................................................................................... 352 12.4 interrupt sources......................................................................................................... ....... 354 12.5 8-bit timer application example ..................................................................................... 355 12.6 usage notes ............................................................................................................... ........ 356 12.6.1 contention between tcnt write and clear........................................................ 356 12.6.2 contention between tcnt write and increment ................................................ 357 12.6.3 contention between tcor write and compare-match ...................................... 358 12.6.4 contention between compare-matches a and b ................................................. 359 12.6.5 switching of internal clocks and tcnt operation............................................. 359 section 13 timer connection ........................................................................................... 363 13.1 overview.................................................................................................................. .......... 363 13.1.1 features ................................................................................................................ 363 13.1.2 block diagram...................................................................................................... 364 13.1.3 input and output pins........................................................................................... 365 13.1.4 register configuration ......................................................................................... 366 13.2 register descriptions..................................................................................................... .... 366 13.2.1 timer connection register i (tconri).............................................................. 366 13.2.2 timer connection register o (tconro) .......................................................... 369 13.2.3 timer connection register s (tconrs)............................................................ 371 13.2.4 edge sense register (sedgr) ............................................................................ 373 13.2.5 module stop control register (mstpcr) .......................................................... 375 13.3 operation ................................................................................................................. .......... 376 13.3.1 pwm decoding (pdc signal generation) .......................................................... 376 13.3.2 clamp waveform generation (cl1/cl2/cl3 signal generation) ..................... 378 13.3.3 measurement of 8-bit timer divided waveform period .................................... 379 13.3.4 ihi signal and 2fh modification ......................................................................... 381 13.3.5 ivi signal fall modification and ihi synchronization........................................ 383 13.3.6 internal synchronization signal generation (ihg/ivg/cl4 signal generation) 384 13.3.7 hsynco output.................................................................................................. 387 13.3.8 vsynco output.................................................................................................. 388 13.3.9 cblank output.................................................................................................. 389 section 14 watchdog timer (wdt) .............................................................................. 391 14.1 overview.................................................................................................................. .......... 391 14.1.1 features ................................................................................................................ 391 14.1.2 block diagram...................................................................................................... 392 14.1.3 pin configuration ................................................................................................. 393
x 14.1.4 register configuration.......................................................................................... 394 14.2 register descriptions..................................................................................................... .... 394 14.2.1 timer counter (tcnt) ........................................................................................ 394 14.2.2 timer control/status register (tcsr) ................................................................ 395 14.2.3 system control register (syscr) ...................................................................... 399 14.2.4 notes on register access ..................................................................................... 400 14.3 operation ................................................................................................................. .......... 401 14.3.1 watchdog timer operation.................................................................................. 401 14.3.2 interval timer operation...................................................................................... 402 14.3.3 timing of setting of overflow flag (ovf) ......................................................... 403 14.3.4 reso signal output timing................................................................................ 404 14.4 interrupts................................................................................................................ ............ 404 14.5 usage notes ............................................................................................................... ........ 405 14.5.1 contention between timer counter (tcnt) write and increment ..................... 405 14.5.2 changing value of cks2 to cks0...................................................................... 405 14.5.3 switching between watchdog timer mode and interval timer mode................ 405 14.5.4 system reset by reso signal............................................................................. 406 14.5.5 counter value in transitions between high-speed mode, subactive mode, and watch mode .................................................................................................. 406 14.5.6 ovf flag clear condition ................................................................................... 407 section 15 serial communication interface (sci, irda) ........................................ 409 15.1 overview.................................................................................................................. .......... 409 15.1.1 features ................................................................................................................ 409 15.1.2 block diagram...................................................................................................... 411 15.1.3 pin configuration ................................................................................................. 412 15.1.4 register configuration ......................................................................................... 412 15.2 register descriptions..................................................................................................... .... 414 15.2.1 receive shift register (rsr)............................................................................... 414 15.2.2 receive data register (rdr) .............................................................................. 414 15.2.3 transmit shift register (tsr).............................................................................. 415 15.2.4 transmit data register (tdr) ............................................................................. 415 15.2.5 serial mode register (smr)................................................................................ 416 15.2.6 serial control register (scr).............................................................................. 418 15.2.7 serial status register (ssr)................................................................................. 422 15.2.8 bit rate register (brr)....................................................................................... 426 15.2.9 serial interface mode register (scmr) .............................................................. 433 15.2.10 module stop control register (mstpcr) .......................................................... 434 15.2.11 keyboard comparator control register (kbcomp) .......................................... 435 15.3 operation ................................................................................................................. .......... 437 15.3.1 overview .............................................................................................................. 43 7 15.3.2 operation in asynchronous mode........................................................................ 439 15.3.3 multiprocessor communication function............................................................ 450
xi 15.3.4 operation in synchronous mode.......................................................................... 458 15.3.5 irda operation .................................................................................................... 467 15.4 sci interrupts ............................................................................................................ ........ 470 15.5 usage notes ............................................................................................................... ........ 471 section 16 i 2 c bus interface ............................................................................................. 475 16.1 overview.................................................................................................................. .......... 475 16.1.1 features ................................................................................................................ 475 16.1.2 block diagram...................................................................................................... 476 16.1.3 input/output pins.................................................................................................. 478 16.1.4 register configuration ......................................................................................... 479 16.2 register descriptions..................................................................................................... .... 480 16.2.1 i 2 c bus data register (icdr).............................................................................. 480 16.2.2 slave address register (sar) ............................................................................. 483 16.2.3 second slave address register (sarx).............................................................. 484 16.2.4 i 2 c bus mode register (icmr) ........................................................................... 485 16.2.5 i 2 c bus control register (iccr) ......................................................................... 488 16.2.6 i 2 c bus status register (icsr)............................................................................ 495 16.2.7 serial/timer control register (stcr) ................................................................ 500 16.2.8 ddc switch register (ddcswr) ...................................................................... 501 16.2.9 module stop control register (mstpcr) .......................................................... 503 16.3 operation ................................................................................................................. .......... 504 16.3.1 i 2 c bus data format............................................................................................. 504 16.3.2 master transmit operation .................................................................................. 506 16.3.3 master receive operation .................................................................................... 508 16.3.4 slave receive operation ...................................................................................... 511 16.3.5 slave transmit operation..................................................................................... 513 16.3.6 iric setting timing and scl control ................................................................ 515 16.3.7 automatic switching from formatless mode to i 2 c bus format........................ 516 16.3.8 operation using the dtc .................................................................................... 518 16.3.9 noise canceler...................................................................................................... 519 16.3.10 sample flowcharts ............................................................................................... 519 16.3.11 initialization of internal state............................................................................... 523 16.4 usage notes ............................................................................................................... ........ 525 section 17 keyboard buffer controller ........................................................................ 531 17.1 overview.................................................................................................................. .......... 531 17.1.1 features ................................................................................................................ 531 17.1.2 block diagram...................................................................................................... 532 17.1.3 input/output pins.................................................................................................. 533 17.1.4 register configuration ......................................................................................... 533 17.2 register descriptions..................................................................................................... .... 534 17.2.1 keyboard control register h (kbcrh) ............................................................. 534
xii 17.2.2 keyboard control register l (kbcrl) .............................................................. 536 17.2.3 keyboard data buffer register (kbbr) ............................................................. 538 17.2.4 module stop control register (mstpcr) .......................................................... 538 17.3 operation ................................................................................................................. .......... 539 17.3.1 receive operation ................................................................................................ 539 17.3.2 transmit operation .............................................................................................. 541 17.3.3 receive abort....................................................................................................... 544 17.3.4 kclki and kdi read timing ............................................................................. 547 17.3.5 kclko and kdo write timing ......................................................................... 547 17.3.6 kbf setting timing and kclk control ............................................................. 548 17.3.7 receive timing .................................................................................................... 549 17.3.8 kclk fall interrupt operation............................................................................ 550 17.3.9 usage note ........................................................................................................... 551 section 18a host interface x-bus interface (xbs) .............................................................................. 553 18a.1 overview .................................................................................................................. ........ 553 18a.1.1 features ............................................................................................................ 553 18a.1.2 block diagram.................................................................................................. 554 18a.1.3 input and output pins....................................................................................... 555 18a.1.4 register configuration ..................................................................................... 556 18a.2 register descriptions..................................................................................................... ... 557 18a.2.1 system control register (syscr) .................................................................. 557 18a.2.2 system control register 2 (syscr2) ............................................................. 558 18a.2.3 host interface control register (hicr) .......................................................... 559 18a.2.4 input data register (idr) ................................................................................ 561 18a.2.5 output data register (odr)............................................................................ 561 18a.2.6 status register (str) ....................................................................................... 562 18a.2.7 module stop control register (mstpcr) ...................................................... 564 18a.3 operation ................................................................................................................. ......... 564 18a.3.1 host interface activation ................................................................................. 564 18a.3.2 control states ................................................................................................... 566 18a.3.3 a20 gate .......................................................................................................... 566 18a.3.4 host interface pin shutdown function ............................................................ 568 18a.4 interrupts ................................................................................................................ .......... 570 18a.4.1 ibf1, ibf2, ibf3, ibf4 ................................................................................... 570 18a.4.2 hirq11, hirq1, hirq12, hirq3, and hirq4 ............................................ 570 18a.5 usage note ................................................................................................................ ....... 572 section 18b host interface lpc interface (lpc) .................................................................................. 573 18b.1 overview ................................................................................................................. ......... 573 18b.1.1 features ............................................................................................................ 573
xiii 18b.1.2 block diagram.................................................................................................. 574 18b.1.3 pin configuration ............................................................................................. 575 18b.1.4 register configuration ..................................................................................... 576 18b.2 register descriptions..................................................................................................... ... 577 18b.2.1 system control registers (syscr, syscr2) ................................................ 577 18b.2.2 host interface control registers 0 and 1 (hicr0, hicr1) ............................ 578 18b.2.3 host interface control registers 2 and 3 (hicr2, hicr3) ............................ 585 18b.2.4 lpc channel 3 address register (ladr3) .................................................... 588 18b.2.5 input data registers (idr1, idr2, idr3)....................................................... 589 18b.2.6 output data registers (odr1, odr2, odr3)................................................ 590 18b.2.7 two-way data registers (twr0 to twr15)................................................. 591 18b.2.8 status registers (str1, str2, str3)............................................................. 592 18b.2.9 serirq control registers (sirqcr0, sirqcr1) ........................................ 595 18b.2.10 module stop control register (mstpcr) ...................................................... 603 18b.3 operation ................................................................................................................. ......... 604 18b.3.1 host interface activation ................................................................................. 604 18b.3.2 lpc i/o cycles ................................................................................................ 604 18b.3.3 a20 gate .......................................................................................................... 606 18b.3.4 host interface shutdown function (lpcpd)................................................... 609 18b.3.5 host interface serial interrupt operation (serirq) ....................................... 612 18b.3.6 host interface clock start request (clkrun) .............................................. 615 18b.4 interrupt sources ......................................................................................................... ..... 616 18b.4.1 ibf1, ibf2, ibf3, erri .................................................................................. 616 18b.4.2 smi, hirq1, hirq6, hirq9, hirq10, hirq11, hirq12 .......................... 616 18b.5 usage notes............................................................................................................... ....... 618 section 19 d/a converter ................................................................................................. 621 19.1 overview................................................................................................................... ......... 621 19.1.1 features ................................................................................................................ 621 19.1.2 block diagram...................................................................................................... 621 19.1.3 input and output pins........................................................................................... 623 19.1.4 register configuration ......................................................................................... 623 19.2 register descriptions...................................................................................................... ... 624 19.2.1 d/a data registers 0 and 1 (dadr0, dadr1).................................................. 624 19.2.2 d/a control register (dacr)............................................................................. 624 19.2.3 module stop control register (mstpcr) .......................................................... 626 19.3 operation .................................................................................................................. ......... 627 section 20 a/d converter ................................................................................................. 629 20.1 overview................................................................................................................... ......... 629 20.1.1 features ................................................................................................................ 629 20.1.2 block diagram...................................................................................................... 630 20.1.3 pin configuration ................................................................................................. 631
xiv 20.1.4 register configuration ......................................................................................... 632 20.2 register descriptions...................................................................................................... ... 632 20.2.1 a/d data registers a to d (addra to addrd).............................................. 632 20.2.2 a/d control/status register (adcsr)................................................................ 633 20.2.3 a/d control register (adcr)............................................................................. 636 20.2.4 keyboard comparator control register (kbcomp) .......................................... 637 20.2.5 module stop control register (mstpcr) .......................................................... 638 20.3 interface to bus master.................................................................................................... .. 639 20.4 operation .................................................................................................................. ......... 640 20.4.1 single mode (scan = 0) ..................................................................................... 640 20.4.2 scan mode (scan = 1) ....................................................................................... 642 20.4.3 input sampling and a/d conversion time.......................................................... 644 20.4.4 external trigger input timing ............................................................................. 645 20.5 interrupts................................................................................................................. ........... 645 20.6 usage notes ................................................................................................................ ....... 646 section 21 ram ................................................................................................................... 653 21.1 overview................................................................................................................... ......... 653 21.1.1 block diagram...................................................................................................... 653 21.1.2 register configuration ......................................................................................... 654 21.2 system control register (syscr).................................................................................... 654 21.3 operation .................................................................................................................. ......... 655 21.3.1 expanded mode (modes 1, 2, and 3 (expe = 1))................................................ 655 21.3.2 single-chip mode (modes 2 and 3 (expe = 0)) ................................................. 655 section 22 rom ................................................................................................................... 657 22.1 overview................................................................................................................... ......... 657 22.1.1 block diagram...................................................................................................... 657 22.1.2 register configuration.......................................................................................... 658 22.2 register descriptions...................................................................................................... ... 658 22.2.1 mode control register (mdcr).......................................................................... 658 22.3 operation .................................................................................................................. ......... 659 22.4 overview of flash memory............................................................................................... 660 22.4.1 features ................................................................................................................ 660 22.4.2 block diagram...................................................................................................... 661 22.4.3 flash memory operating modes.......................................................................... 662 22.4.4 pin configuration ................................................................................................. 666 22.4.5 register configuration ......................................................................................... 666 22.5 register descriptions...................................................................................................... ... 667 22.5.1 flash memory control register 1 (flmcr1)..................................................... 667 22.5.2 flash memory control register 2 (flmcr2)..................................................... 669 22.5.3 erase block registers 1 and 2 (ebr1, ebr2)..................................................... 670 22.5.4 serial/timer control register (stcr) ................................................................ 671
xv 22.6 on-board programming modes ........................................................................................ 672 22.6.1 boot mode............................................................................................................ 673 22.6.2 user program mode ............................................................................................. 678 22.7 programming/erasing flash memory................................................................................ 679 22.7.1 program mode...................................................................................................... 679 22.7.2 program-verify mode .......................................................................................... 680 22.7.3 erase mode........................................................................................................... 682 22.7.4 erase-verify mode ............................................................................................... 682 22.8 flash memory protection .................................................................................................. 68 4 22.8.1 hardware protection............................................................................................. 684 22.8.2 software protection .............................................................................................. 684 22.8.3 error protection .................................................................................................... 685 22.9 interrupt handling when programming/erasing flash memory ....................................... 686 22.10 flash memory programmer mode .................................................................................... 687 22.10.1 programmer mode setting ................................................................................... 687 22.10.2 socket adapters and memory map...................................................................... 688 22.10.3 writer mode operation ........................................................................................ 688 22.10.4 memory read mode............................................................................................. 690 22.10.5 auto-program mode ............................................................................................ 693 22.10.6 auto-erase mode.................................................................................................. 694 22.10.7 status read mode................................................................................................. 696 22.10.8 status polling........................................................................................................ 6 97 22.10.9 writer mode transition time .............................................................................. 697 22.10.10 notes on memory programming ....................................................................... 698 22.11 flash memory programming and erasing precautions ..................................................... 698 section 23 clock pulse generator .................................................................................. 701 23.1 overview................................................................................................................... ......... 701 23.1.1 block diagram...................................................................................................... 701 23.1.2 register configuration ......................................................................................... 701 23.2 register descriptions...................................................................................................... ... 702 23.2.1 standby control register (sbycr) .................................................................... 702 23.2.2 low-power control register (lpwrcr)............................................................ 703 23.3 oscillator................................................................................................................. ........... 703 23.3.1 connecting a crystal resonator ........................................................................... 703 23.3.2 external clock input ............................................................................................ 705 23.4 duty adjustment circuit.................................................................................................... 708 23.5 medium-speed clock divider........................................................................................... 708 23.6 bus master clock selection circuit .................................................................................. 708 23.7 subclock input circuit..................................................................................................... .. 708 23.8 subclock waveform shaping circuit................................................................................ 709 23.9 clock selection circuit.................................................................................................... .. 709 23.10 x1 and x2 pins............................................................................................................ ...... 710
xvi section 24 power-down state .......................................................................................... 711 24.1 overview................................................................................................................... ......... 711 24.1.1 register configuration ......................................................................................... 715 24.2 register descriptions...................................................................................................... ... 715 24.2.1 standby control register (sbycr) .................................................................... 715 24.2.2 low-power control register (lpwrcr)............................................................ 717 24.2.3 timer control/status register (tcsr) ................................................................ 719 24.2.4 module stop control register (mstpcr) .......................................................... 720 24.3 medium-speed mode ........................................................................................................ 72 1 24.4 sleep mode................................................................................................................. ....... 722 24.4.1 sleep mode........................................................................................................... 722 24.4.2 clearing sleep mode ............................................................................................ 722 24.5 module stop mode ........................................................................................................... . 723 24.5.1 module stop mode ............................................................................................... 723 24.5.2 usage note ........................................................................................................... 724 24.6 software standby mode .................................................................................................... 72 5 24.6.1 software standby mode ....................................................................................... 725 24.6.2 clearing software standby mode ........................................................................ 725 24.6.3 setting oscillation settling time after clearing software standby mode .......... 726 24.6.4 software standby mode application example .................................................... 726 24.6.5 usage note ........................................................................................................... 727 24.7 hardware standby mode ................................................................................................... 728 24.7.1 hardware standby mode...................................................................................... 728 24.7.2 hardware standby mode timing ......................................................................... 729 24.8 watch mode ................................................................................................................. ..... 730 24.8.1 watch mode ......................................................................................................... 730 24.8.2 clearing watch mode .......................................................................................... 730 24.9 subsleep mode .............................................................................................................. .... 731 24.9.1 subsleep mode ..................................................................................................... 731 24.9.2 clearing subsleep mode ...................................................................................... 731 24.10 subactive mode ............................................................................................................ ..... 732 24.10.1 subactive mode.................................................................................................... 732 24.10.2 clearing subactive mode ..................................................................................... 732 24.11 direct transition......................................................................................................... ....... 733 24.11.1 overview of direct transition.............................................................................. 733 section 25 electrical characteristics .............................................................................. 735 25.1 absolute maximum ratings.............................................................................................. 735 25.2 dc characteristics ......................................................................................................... .... 736 25.3 ac characteristics ......................................................................................................... .... 742 25.3.1 clock timing........................................................................................................ 743 25.3.2 control signal timing.......................................................................................... 745 25.3.3 bus timing ........................................................................................................... 747
xvii 25.3.4 timing of on-chip supporting modules ............................................................. 754 25.4 a/d conversion characteristics ........................................................................................ 764 25.5 d/a conversion characteristics ........................................................................................ 765 25.6 flash memory characteristics ........................................................................................... 766 25.7 usage note (internal step-down) ..................................................................................... 768 appendix a instruction set ............................................................................................... 769 a.1 instruction................................................................................................................. ......... 769 a.2 instruction codes ........................................................................................................... .... 787 a.3 operation code map.......................................................................................................... 801 a.4 number of states required for execution......................................................................... 805 a.5 bus states during instruction execution .......................................................................... 818 appendix b internal i/o registers .................................................................................. 834 b.1 addresses................................................................................................................... ........ 834 b.2 register selection conditions............................................................................................ 843 b.3 functions................................................................................................................... ......... 853 appendix c i/o port block diagrams ........................................................................... 952 c.1 port 1 block diagram........................................................................................................ 952 c.2 port 2 block diagrams ...................................................................................................... 9 53 c.3 port 3 block diagram....................................................................................................... . 956 c.4 port 4 block diagrams ...................................................................................................... 9 59 c.5 port 5 block diagrams ...................................................................................................... 9 66 c.6 port 6 block diagrams ...................................................................................................... 9 69 c.7 port 7 block diagrams ...................................................................................................... 9 74 c.8 port 8 block diagrams ...................................................................................................... 9 75 c.9 port 9 block diagrams ...................................................................................................... 9 82 c.10 port a block diagrams...................................................................................................... 987 c.11 port b block diagram ....................................................................................................... 990 c.12 port c, d, e, f, g block diagram ..................................................................................... 993 appendix d pin states ........................................................................................................ 994 d.1 port states in each processing state.................................................................................. 994 appendix e timing of transition to and recovery from hardware standby mode ................................................................................................ 996 e.1 timing of transition to hardware standby mode ............................................................ 996 e.2 timing of recovery from hardware standby mode......................................................... 996
xviii appendix f product codes ................................................................................................ 997 appendix g package dimensions ................................................................................... 998
1 section 1 overview 1.1 overview the h8s/2149 and h8s/2169 f-ztat is a microcomputer (mcu) built around the h8s/2000 cpu, employing hitachi? proprietary architecture, and equipped with on-chip supporting functions required for system configuration. the h8s/2000 cpu has an internal 32-bit architecture, is provided with sixteen 16-bit general registers and a concise, optimized instruction set designed for high-speed operation, and can address a 16-mbyte linear address space. the instruction set is upward-compatible with h8/300 and h8/300h cpu instructions at the object-code level, facilitating migration from the h8/300, h8/300l, or h8/300h series. on-chip supporting functions required for system configuration include a data transfer controller (dtc) bus master, rom and ram memory, a 16-bit free-running timer module (frt), an 8-bit timer module (tmr), watchdog timer module (wdt), two pwm timers (pwm and pwmx), serial communication interface (sci), ps/2-compatible keyboard buffer controller, i 2 c bus interface (iic), host interfaces (hif:lpc and hif:xbs), d/a converter (dac), a/d converter (adc), and i/o ports. the h8s/2169 f-ztat has all of the same i/o ports as the h8s/2149 f- ztat, plus 40 additional i/o ports. the on-chip rom is 64-kbyte flash memory (f-ztat*). the rom is connected to the cpu by a 16-bit data bus, enabling both byte and word data to be accessed in one state. instruction fetching has been speeded up, and processing speed increased. three operating modes, modes 1 to 3, are provided, and there is a choice of address space and single-chip mode or externally expanded modes. the features of the h8s/2149 and h8s/2169 f-ztat are shown in table 1.1. note: * f-ztat is a trademark of hitachi, ltd.
2 table 1.1 overview item specifications cpu general-register architecture ? sixteen 16-bit general registers (also usable as sixteen 8-bit registers or eight 32-bit registers) high-speed operation suitable for realtime control ? maximum operating frequency: 10 mhz/3 v ? high-speed arithmetic operations 8/16/32-bit register-register add/subtract: 100 ns (10 mhz operation) 16 16-bit register-register multiply: 2000 ns (10 mhz operation) 32 ? 16-bit register-register divide: 2000 ns (10 mhz operation) instruction set suitable for high-speed operation ? sixty-five basic instructions ? 8/16/32-bit transfer/arithmetic and logic instructions ? unsigned/signed multiply and divide instructions ? powerful bit-manipulation instructions two cpu operating modes ? normal mode: 64-kbyte address space ? advanced mode: 16-mbyte address space operating modes three mcu operating modes external data bus mode cpu operating mode description on-chip rom initial value max. value 1 normal expanded mode with on-chip rom disabled disabled 8 bits 16 bits 2 advanced expanded mode with on-chip rom enabled enabled 8 bits 16 bits single-chip mode none 3 normal expanded mode with on-chip rom enabled enabled 8 bits 16 bits single-chip mode none bus controller 2-state or 3-state access space can be designated for external expansion areas number of program wait states can be set for external expansion areas
3 item specifications data transfer controller (dtc) can be activated by internal interrupt or software multiple transfers or multiple types of transfer possible for one activation source transfer possible in repeat mode, block transfer mode, etc. request can be sent to cpu for interrupt that activated dtc 16-bit free-running timer module (frt: 1 channel) one 16-bit free-running counter (usable for external event counting) two output compare outputs four input capture inputs (with buffer operation capability) 8-bit timer module (2 channels: tmr0, tmr1) each channel has: one 8-bit up-counter (usable for external event counting) two timer constant registers the two channels can be connected timer connection and 8-bit timer module (tmr) (2 channels: tmrx, tmry) input/output and frt, tmr1, tmrx, tmry can be interconnected measurement of input signal or frequency-divided waveform pulse width and cycle (frt, tmr1) output of waveform obtained by modification of input signal edge (frt, tmr1) determination of input signal duty cycle (tmrx) output of waveform synchronized with input signal (frt, tmrx, tmry) automatic generation of cyclical waveform (frt, tmry) watchdog timer module (wdt: 2 channels) watchdog timer or interval timer function selectable subclock operation capability (channel 1 only) 8-bit pwm timer (pwm) up to 16 outputs pulse duty cycle settable from 0 to 100% resolution: 1/256 625 khz maximum carrier frequency (10 mhz operation) 14-bit pwm timer (pwmx) up to 2 outputs resolution: 1/16384 156.25 khz maximum carrier frequency (10 mhz operation) serial communi- cation interface (sci: 2 channels, sci0, sci1) asynchronous mode or synchronous mode selectable multiprocessor communication function
4 item specifications sci with irda: 1 channel (sci2) asynchronous mode or synchronous mode selectable multiprocessor communication function conforms to irda standard version 1.0 irda format encoding/decoding of txd and rxd keyboard buffer controller (ps2: 3 channels) conforms to ps/2 interface direct manipulation of transmission output by software receive data input to 8-bit shift register data/receive/completed interrupt, parity error detection, stop bit monitoring host interface (hif:xbs) 8-bit host interface (isa/x-bus) port five host interrupt requests (hirq11, hirq1, hirq12, hirq3, hirq4) normal and fast a20 gate output four register sets (each comprising two data registers and a status register) host interface (hif:lpc) single-channel lpc port xbs three register set equivalence, plus 16 two-way register bytes seven serial host interrupt requests (smi, hirq1, hirq6, hirq9 to hirq12) normal and fast a20 gate output three register sets (each comprising two data registers and a status register) keyboard controller matrix keyboard control using keyboard scan with wakeup interrupt and sense port configuration a/d converter resolution: 10 bits input: ? 8 channels (dedicated analog pins) ? 16 channels (same pins as keyboard sense port) high-speed conversion: 13.4 m s minimum conversion time (10 mhz operation) single or scan mode selectable sample-and-hold function a/d conversion can be activated by external trigger or timer trigger
5 item specifications d/a converter resolution: 8 bits output: 2 channels i/o ports (h8s/2149) 74 input/output pins (including 24 with led drive capability) eight input-only pins eight of the input/output pins are driven by vccb (separate power supply) i/o ports (h8s/2169) 114 input/output pins (including 24 with led drive capability) eight input-only pins 32 of the input/output pins are driven by vccb (separate power supply) memory flash memory: 64 kbytes high-speed static ram: 2 kbytes interrupt controller nine external interrupt pins (nmi, irq0 to irq7 ) 48 internal interrupt sources three priority levels settable power-down state medium-speed mode sleep mode module stop mode software standby mode hardware standby mode subclock operation clock pulse generator built-in duty correction circuit packages (h8s/2149) 100-pin plastic qfp (fp-100b) 100-pin plastic tqfp (tfp-100b) packages (h8s/2169) 144-pin plastic tqfp (tfp-144) i 2 c bus interface (iic: 2 channels) conforms to philips i 2 c bus interface standard single master mode/slave mode arbitration lost condition can be identified supports two slave addresses
6 item specifications product lineup product code (f-ztat version) rom/ram (bytes) packages hd64f2149yv 64 k/2 k fp-100b, tfp-100b hd64f2169yv 64 k/2 k tfp-144
7 1.2 block diagram figure 1.1(a) is a block diagram of the h8s/2149. figure 1.1(b) is a block diagram of the h8s/2169. h8s/2000 cpu dtc interrup controller wdt0, wdt1 keyboard buffer controller 3 channels rom ram 8-bit pwm 16-bit frt 8-bit timer 4 channels (tmr0, tmr1, tmrx, tmry) timer connection 14-bit pwm host interfaces (lpc, xbs) 10-bit a/d converter 8-bit d/a converter sci 3 channels (irda 1 channel) iic 2 channels p17/a7/pw7 p16/a6/pw6 p15/a5/pw5 p14/a4/pw4 p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 p27/a15/pw15/cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 pa7/a23/ kin15 /cin15/ps2cd pa6/a22/ kin14 /cin14/ps2cc pa5/a21/ kin13 /cin13/ps2bd pa4/a20/ kin12 /cin12/ps2bc pa3/a19/ kin11 /cin11/ps2ad pa2/a18/ kin10 /cin10/ps2ac pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 p37/d15/hdb7/serirq p36/d14/hdb6/lclk p35/d13/hdb5/ lreset p34/d12/hdb4/ lframe p33/d11/hdb3/lad3 p32/d10/hdb2/lad2 p31/d9/hdb1/lad1 p30/d8/hdb0/lad0 pb7/d7/ wue7 pb6/d6/ wue6 pb5/d5/ wue5 pb4/d4/ wue4 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 pb1/d1/ wue1 /hirq4/lsci pb0/d0/ wue0 /hirq3/ lsmi p97/ wait /sda0 p96/?/excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg / ecs2 p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix p47/pwx1 p46/pwx0 p45/tmri1/hirq12/csynci p44/tmo1/hirq1/hsynco p43/tmci1/hirq11/hsynci p42/tmri0/sck2/sda1 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd p52/sck0/scl0 p51/rxd0 p50/txd0 p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 p86/ irq5 /sck1/scl1 p85/ irq4 /rxd1 p84/ irq3 /txd1 p83/ lpcpd p82/hifsd/ clkrun p81/ cs2 /ga20 p80/ha0/ pme avref avcc avss res xtal extal vccb md1 md0 nmi stby reso vcc vcl vss vss vss vss port 8 port 7 clock pulse generator internal data bus internal address bus bus controller port a port 2 port 1 port 3 port b port 9 port 6 port 4 port 5 figure 1.1(a) internal block diagram of h8s/2149
8 h8s/2000 cpu dtc bus controller interrupt controller wdt0, wdt1 keyboard buffer controller 3 channels rom ram 8-bit pwm 16-bit frt 8-bit timer 4 channels (tmr0, tmr1, tmrx, tmry) timer connection 14-bit pwm host interfaces (lpc, xbs) 10-bit a/d converter 8-bit d/a converter sci 3 channels (irda 1 channel) iic 2 channels p17/a7/pw7 p16/a6/pw6 p15/a5/pw5 p14/a4/pw4 p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 p27/a15/pw15/cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 pa7/a23/ kin15 /cin15/ps2cd pa6/a22/ kin14 /cin14/ps2cc pa5/a21/ kin13 /cin13/ps2bd pa4/a20/ kin12 /cin12/ps2bc pa3/a19/ kin11 /cin11/ps2ad pa2/a18/ kin10 /cin10/ps2ac pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 p37/d15/hdb7/serirq p36/d14/hdb6/lclk p35/d13/hdb5/ lreset p34/d12/hdb4/ lframe p33/d11/hdb3/lad3 p32/d10/hdb2/lad2 p31/d9/hdb1/lad1 p30/d8/hdb0/lad0 pb7/d7/ wue7 pb6/d6/ wue6 pb5/d5/ wue5 pb4/d4/ wue4 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 pb1/d1/ wue1 /hirq4/lsci pb0/d0/ wue0 /hirq3/ lsmi p97/ wait /sda0 p96/?/excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg / ecs2 p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix p47/pwx1 p46/pwx0 p45/tmri1/hirq12/csynci p44/tmo1/hirq1/hsynco p43/tmci1/hirq11/hsynci p42/tmri0/sck2/sda1 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd p52/sck0/scl0 p51/rxd0 p50/txd0 x1 x2 res xtal extal vccb md1 md0 nmi stby reso vcc vcc vcl vss vss vss vss vss clock pulse generator internal data bus internal address bus port 9 port 6 port 4 port 5 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 port d port c port b port 3 port 1 port 2 port a p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 p86/ irq5 /sck1/scl1 p85/ irq4 /rxd1 p84/ irq3 /txd1 p83/ lpcpd p82/hifsd/ clkrun p81/ cs2 /ga20 p80/ha0/ pme avref avcc avss port 8 port 7 pg7 pg6 pg5 pg4 pg3 pg2 pg1 pg0 port g pf7 pf6 pf5 pf4 pf3 pf2 pf1 pf0 port f pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 port e figure 1.1(b) internal block diagram of h8s/2169
9 1.3 pin arrangement and functions 1.3.1 pin arrangement figure 1.2(a) shows the arrangement of the h8s/2149? pins. figure 1.2(b) shows the arrangement of the h8s/2169? pins. fp-100b tfp-100b (top view) 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 res xtal extal vccb md1 md0 nmi stby vcl pa7/a23/cin15/ kin15 /ps2cd pa6/a22/cin14/ kin14 /ps2cc p52/sck0/scl0 p51/rxd0 p50/txd0 vss p97/ wait /sda0 p96/ f /excl p95/ as / ios / cs1 p94/ hwr / iow pa5/a21/cin13/ kin13 /ps2bd pa4/a20/cin12/ kin12 /ps2bc p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / ecs2 / irq2 / adtrg p14/a4/pw4 p15/a5/pw5 p16/a6/pw6 p17/a7/pw7 vss vss pb4/d4/ wue4 pb5/d5/ wue5 p20/a8/pw8 p21/a9/pw9 p22/a10/pw10 p23/a11/pw11 p24/a12/pw12 p25/a13/pw13 p26/a14/pw14 p27/a15/pw15/cblank vcc pb6/d6/ wue6 pb7/d7/ wue7 p47/pwx1 p46/pwx0 p45/tmri1/hirq12/csynci p44/tmo1/hirq1/hsynco p43/tmci1/hirq11/hsynci p42/tmri0/sck2/sda1 p41/tmo0/rxd2/irrxd p40/tmci0/txd2/irtxd pa0/a16/cin8/ kin8 pa1/a17/cin9/ kin9 avss p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 avcc avref p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo pa2/a18/cin10/ kin10 /ps2ac pa3/a19/cin11/ kin11 /ps2ad p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 p30/d8 /hdb0/lad0 p31/d9 /hdb1/lad1 p32/d10/hdb2/lad2 p33/d11/hdb3/lad3 p34/d12/hdb4/ lframe p35/d13/hdb5/ lreset p36/d14/hdb6/lclk p37/d15/hdb7/serirq pb1/d1/hirq4/ wue1 /lsci pb0/d0/hirq3/ wue0 / lsmi vss p80/ha0/ pme p81/ cs2 /ga20 p82/hifsd/ clkrun p83/ lpcpd p84/ irq3 /txd1 p85/ irq4 /rxd1 p86/ irq5 /sck1/scl1 reso 55 54 53 52 51 12345678910111213141516171819202122232425 figure 1.2(a) h8s/2149 pin arrangement (fp-100b, tfp-100b: top view)
10 tfp-144 (top view) 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 vcc p43/tmci1/hirq11/hsynci p44/tmo1/hirq1/hsynco p45/tmri1/hirq12/csynci p46/pwx0 p47/pwx1 vss res md1 md0 nmi stby vcl p52/sck0/scl0 p51/ rxd0 p50/txd0 p97/ wait /sda0 p96/?/ excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / ecs2 / irq2 / adtrg pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 pa7/a23/cin15/ kin15 /ps2cd pa6/a22/cin14/ kin14 /ps2cc pa5/a21/cin13/ kin13 /ps2bd vccb p13/a3/pw3 p14/a4/pw4 p15/a5/pw5 p16/a6/pw6 p17/a7/pw7 p20/a8/pw8 p21/a9/pw9 p22/a10/pw10 p23/a11/pw11 p24/a12/pw12 p25/a13/pw13 p26/a14/pw14 p27/a15/pw15/cblank vss pc0 pc1 pc2 pc3 pc4 pc5 pc6 pc7 vcc p67/tmox/cin7/ kin7 / irq7 p66/ftob/cin6/ kin6 / irq6 p65/ftid/cin5/ kin5 p64/ftic/cin4/ kin4 /clampo p63/ftib/cin3/ kin3 /vfbacki p62/ftia/cin2/ kin2 /vsynci/tmiy p61/ftoa/cin1/ kin1 /vsynco p60/ftci/cin0/ kin0 /hfbacki/tmix avref avcc p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 avss pd0 pd1 pd2 pd3 pd4 pd5 pd6 pd7 pg0 pg1 pg2 pg3 pg4 pg5 pg6 pg7 pf0 pf1 pf2 pf3 pf4 pf5 pf6 pf7 vss pa0/a16/cin8/ kin8 pa1/a17/cin9/ kin9 pa2/a18/cin10/ kin10 /ps2ac pa3/a19/cin11/ kin11 /ps2ad pa4/a20/cin12/ kin12 /ps2bc p12/a2/pw2 p11/a1/pw1 vss p10/a0/pw0 pb7/d7/ wue7 pb6/d6/ wue6 pb5/d5/ wue5 pb4/d4/ wue4 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 pb1/d1/hirq4/ wue1 /lsci pb0/d0/hirq3/ wue0 / lsmi p30/d8/hdb0/lad0 p31/d9/hdb1/lad1 p32/d10/hdb2/lad2 p33/d11/hdb3/lad3 p34/d12/hdb4/ lframe p35/d13/hdb5/ lreset p36/d14/hdb6/lclk p37/d15/hdb7/serirq p80/ha0/ pme p81/ cs2 /ga20 p82/hifsd/ clkrun p83/ lpcpd p84/ irq3 /txd1 p85/ irq4 /rxd1 p86/ irq5 /sck1/scl1 p40/tmci0/txd2/irtxd p41/tmo0/rxd2/irrxd p42/tmri0/sck2/sda1 vss x1 x2 reso xtal extal 88 87 86 85 84 12345678910111213141516171819202122232425 26 27 28 29 30 31 32 33 34 35 36 83 82 81 80 79 78 77 76 75 74 73 figure 1.2(b) h8s/2169 pin arrangement (tfp-144: top view)
11 1.3.2 pin functions in each operating mode tables 1.2(a) and table 1.2(b), respectively, show the pin functions of the h8s/2149 and h8s/2169, for each of the operating modes. (b) following the pin number indicates vccb drive, and (n) indicates an nmos push-pull/open-drain drive. table 1.2(a) h8s/2149 pin functions in each operating mode pin name pin no. expanded modes single-chip modes flash memory fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 1 res res res res 2 xtal xtal xtal xtal 3 extal extal extal extal 4 vccb vccb vccb vcc 5 md1 md1 md1 vss 6 md0 md0 md0 vss 7 nmi nmi nmi fa9 8 stby stby stby vcc 9 vcl vcl vcl vcc 10 (b) pa7/cin15/ kin15 / ps2cd pa7/a23/cin15/ kin15 /ps2cd pa7/cin15/ kin15 / ps2cd nc 11 (b) pa6/cin14/ kin14 / ps2cc pa6/a22/cin14/ kin14 /ps2cc pa6/cin14/ kin14 / ps2cc nc 12 (n) p52/sck0/scl0 p52/sck0/scl0 p52/sck0/scl0 nc 13 p51/rxd0 p51/rxd0 p51/rxd0 fa17 14 p50/txd0 p50/txd0 p50/txd0 nc 15 vss vss vss vss 16 (n) p97/ wait /sda0 p97/ wait /sda0 p97/sda0 vcc 17 p96/?excl p96/?excl p96/?excl nc 18 as / ios as / ios p95/ cs1 fa16 19 hwr hwr p94/ iow fa15 20 (b) pa5/cin13/ kin13 / ps2bd pa5/a21/cin13/ kin13 /ps2bd pa5/cin13/ kin13 / ps2bd nc 21 (b) pa4/cin12/ kin12 / ps2bc pa4/a20/cin12/ kin12 /ps2bc pa4/cin12/ kin12 / ps2bc nc
12 pin name pin no. expanded modes single-chip modes flash memory fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 22 rd rd p93/ ior we 23 p92/ irq0 p92/ irq0 p92/ irq0 vss 24 p91/ irq1 p91/ irq1 p91/ irq1 vcc 25 p90/ lwr / irq2 / adtrg p90/ lwr / irq2 / adtrg p90/ ecs2 / irq2 / adtrg vcc 26 p60/ftci/cin0/ kin0 /hfbacki/ tmix p60/ftci/cin0/ kin0 /hfbacki/ tmix p60/ftci/cin0/ kin0 /hfbacki/ tmix nc 27 p61/ftoa/cin1/ kin1 /vsynco p61/ftoa/cin1/ kin1 /vsynco p61/ftoa/cin1/ kin1 /vsynco nc 28 p62/ftia/cin2/ kin2 /vsynci/tmiy p62/ftia/cin2/ kin2 /vsynci/tmiy p62/ftia/cin2/ kin2 /vsynci/tmiy nc 29 p63/ftib/cin3/ kin3 /vfbacki p63/ftib/cin3/ kin3 /vfbacki p63/ftib/cin3/ kin3 /vfbacki nc 30 (b) pa3/cin11/ kin11 / ps2ad pa3/a19/cin11/ kin11 /ps2ad pa3/cin11/ kin11 / ps2ad nc 31 (b) pa2/cin10/ kin10 / ps2ac pa2/a18/cin10/ kin10 /ps2ac pa2/cin10/ kin10 / ps2ac nc 32 p64/ftic/cin4/ kin4 /clampo p64/ftic/cin4/ kin4 /clampo p64/ftic/cin4/ kin4 /clampo nc 33 p65/ftid/cin5/ kin5 p65/ftid/cin5/ kin5 p65/ftid/cin5/ kin5 nc 34 p66/ftob/cin6/ kin6 / irq6 p66/ftob/cin6/ kin6 / irq6 p66/ftob/cin6/ kin6 / irq6 nc 35 p67/tmox/cin7/ kin7 / irq7 p67/tmox/cin7/ kin7 / irq7 p67/tmox/cin7/ kin7 / irq7 vss 36 avref avref avref vcc 37 avcc avcc avcc vcc 38 p70/an0 p70/an0 p70/an0 nc 39 p71/an1 p71/an1 p71/an1 nc 40 p72/an2 p72/an2 p72/an2 nc 41 p73/an3 p73/an3 p73/an3 nc
13 pin name pin no. expanded modes single-chip modes flash memory fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 42 p74/an4 p74/an4 p74/an4 nc 43 p75/an5 p75/an5 p75/an5 nc 44 p76/an6/da0 p76/an6/da0 p76/an6/da0 nc 45 p77/an7/da1 p77/an7/da1 p77/an7/da1 nc 46 avss avss avss vss 47 (b) pa1/cin9/ kin9 pa1/a17/cin9/ kin9 pa1/cin9/ kin9 nc 48 (b) pa0/cin8/ kin8 pa0/a16/cin8/ kin8 pa0/cin8/ kin8 nc 49 p40/tmci0/txd2/ irtxd p40/tmci0/txd2/ irtxd p40/tmci0/txd2/ irtxd nc 50 p41/tmo0/rxd2/ irrxd p41/tmo0/rxd2/ irrxd p41/tmo0/rxd2/ irrxd nc 51 p42/tmri0/sck2/ sda1 p42/tmri0/sck2/ sda1 p42/tmri0/sck2/ sda1 nc 52 p43/tmci1/ hsynci p43/tmci1/ hsynci p43/tmci1/hirq11/ hsynci nc 53 p44/tmo1/ hsynco p44/tmo1/ hsynco p44/tmo1/hirq1/ hsynco nc 54 p45/tmri1/ csynci p45/tmri1/ csynci p45/tmri1/hirq12/ csynci nc 55 p46/pwx0 p46/pwx0 p46/pwx0 nc 56 p47/pwx1 p47/pwx1 p47/pwx1 nc 57 pb7/d7/ wue7 pb7/d7/ wue7 pb7/ wue7 nc 58 pb6/d6/ wue6 pb6/d6/ wue6 pb6/ wue6 nc 59 vcc vcc vcc vcc 60 a15 p27/a15/pw15/ cblank p27/pw15/ cblank ce 61 a14 p26/a14/pw14 p26/pw14 fa14 62 a13 p25/a13/pw13 p25/pw13 fa13 63 a12 p24/a12/pw12 p24/pw12 fa12 64 a11 p23/a11/pw11 p23/pw11 fa11
14 pin name pin no. expanded modes single-chip modes flash memory fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 65 a10 p22/a10/pw10 p22/pw10 fa10 66 a9 p21/a9/pw9 p21/pw9 oe 67 a8 p20/a8/pw8 p20/pw8 fa8 68 pb5/d5/ wue5 pb5/d5/ wue5 pb5/ wue5 nc 69 pb4/d4/ wue4 pb4/d4/ wue4 pb4/ wue4 nc 70 vss vss vss vss 71 vss vss vss vss 72 a7 p17/a7/pw7 p17/pw7 fa7 73 a6 p16/a6/pw6 p16/pw6 fa6 74 a5 p15/a5/pw5 p15/pw5 fa5 75 a4 p14/a4/pw4 p14/pw4 fa4 76 a3 p13/a3/pw3 p13/pw3 fa3 77 a2 p12/a2/pw2 p12/pw2 fa2 78 a1 p11/a1/pw1 p11/pw1 fa1 79 a0 p10/a0/pw0 p10/pw0 fa0 80 pb3/d3/ wue3 pb3/d3/ wue3 pb3/ wue3 / cs4 nc 81 pb2/d2/ wue2 pb2/d2/ wue2 pb2/ wue2 / cs3 nc 82 d8 d8 p30/hdb0/lad0 fo0 83 d9 d9 p31/hdb1/lad1 fo1 84 d10 d10 p32/hdb2/lad2 fo2 85 d11 d11 p33/hdb3/lad3 fo3 86 d12 d12 p34/hdb4/ lframe fo4 87 d13 d13 p35/hdb5/ lreset fo5 88 d14 d14 p36/hdb6/lclk fo6 89 d15 d15 p37/hdb7/serirq fo7 90 pb1/d1/ wue1 pb1/d1/ wue1 pb1/hirq4/ wue1 / lsci nc 91 pb0/d0/ wue0 pb0/d0/ wue0 pb0/hirq3/ wue0 / lsmi nc
15 pin name pin no. expanded modes single-chip modes flash memory fp-100b tfp-100b mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 92 vss vss vss vss 93 p80 p80 p80/ha0/ pme nc 94 p81 p81 p81/ cs2 /ga20 nc 95 p82 p82 p82/hifsd/ clkrun nc 96 p83 p83 p83/ lpcpd nc 97 p84/ irq3 /txd1 p84/ irq3 /txd1 p84/ irq3 /txd1 nc 98 p85/ irq4 /rxd1 p85/ irq 4/rxd1 p85/ irq4 /rxd1 nc 99 p86/ irq5 /sck1/ scl1 p86/ irq5 /sck1/ scl1 p86/ irq5 /sck1/ scl1 nc 100 reso reso reso nc
16 table 1.2(b) h8s/2169 pin functions in each operating mode pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 1 vcc vcc vcc vcc 2 p43/tmci1/ hsynci p43/tmci1/ hsynci p43/tmci1/hirq11/ hsynci nc 3 p44/tmo1/ hsynco p44/tmo1/ hsynco p44/tmo1/hirq1/ hsynco nc 4 p45/tmri1/ csynci p45/tmri1/ csynci p45/tmri1/hirq12/ csynci nc 5 p46/pwx0 p46/pwx0 p46/pwx0 nc 6 p47/pwx1 p47/pwx1 p47/pwx1 nc 7 vss vss vss vss 8 res res res res 9 md1 md1 md1 vss 10 md0 md0 md0 vss 11 nmi nmi nmi fa9 12 stby stby stby vcc 13 vcl vcl vcl vcc 14 (n) p52/sck0/scl0 p52/sck0/scl0 p52/sck0/scl0 fa18 15 p51/rxd0 p51/rxd0 p51/rxd0 fa17 16 p50/txd0 p50/txd0 p50/txd0 nc 17 (n) p97/ wait /sad0 p97/ wait /sda0 p97/sda0 vcc 18 p96/?excl p96/?excl p96/?excl nc 19 as / ios as / ios p95/ cs1 fa16 20 hwr hwr p94/ iow fa15 21 rd rd p93/ ior we 22 p92/ irq0 p92/ irq0 p92/ irq0 vss 23 p91/ irq1 p91/ irq1 p91/ irq1 vcc 24 p90/ lwr / irq2 / adtrg p90/ lwr / irq2 / adtrg p90/ irq2 / adtrg / ecs2 vcc 25 (b) pe7 pe7 pe7 nc 26 (b) pe6 pe6 pe6 nc
17 pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 27 (b) pe5 pe5 pe5 nc 28 (b) pe4 pe4 pe4 nc 29 (b) pe3 pe3 pe3 nc 30 (b) pe2 pe2 pe2 nc 31 (b) pe1 pe1 pe1 nc 32 (b) pe0 pe0 pe0 nc 33 (b) pa7/cin15/ kin15 / ps2cd pa7/a23/cin15/ kin15 /ps2cd pa7/cin15/ kin15 / ps2cd nc 34 (b) pa6/cin14/ kin14 / ps2cc pa6/a22/cin14/ kin14 /ps2cc pa6/cin14/ kin14 / ps2cc nc 35 (b) pa5/cin13/ kin13 / ps2bd pa5/a21/cin13/ kin13 /ps2bd pa5/cin13/ kin13 / ps2bd nc 36 vccb vccb vccb vcc 37 (b) pa4/cin12/ kin12 / ps2bc pa4/a20/cin12/ kin12 /ps2bc pa4/cin12/ kin12 / ps2bc nc 38 (b) pa3/cin11/ kin11 / ps2ad pa3/a19/cin11/ kin11 /ps2ad pa3/cin11/ kin11 / ps2ad nc 39 (b) pa2/cin10/ kin10 / ps2ac pa2/a18/cin10/ kin10 /ps2ac pa2/cin10/ kin10 / ps2ac nc 40 (b) pa1/cin9/ kin9 pa1/a17/cin9/ kin9 pa1/cin9/ kin9 nc 41 (b) pa0/cin8/ kin8 pa0/a16/cin8/ kin8 pa0/cin8/ kin8 nc 42 vss vss vss vss 43 (b) pf7 pf7 pf7 nc 44 (b) pf6 pf6 pf6 nc 45 (b) pf5 pf5 pf5 nc 46 (b) pf4 pf4 pf4 nc 47 (b) pf3 pf3 pf3 nc 48 (b) pf2 pf2 pf2 nc 49 (b) pf1 pf1 pf1 nc 50 (b) pf0 pf0 pf0 nc 51 (b) pg7 pg7 pg7 nc 52 (b) pg6 pg6 pg6 nc
18 pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 53 (b) pg5 pg5 pg5 nc 54 (b) pg4 pg4 pg4 nc 55 (b) pg3 pg3 pg3 nc 56 (b) pg2 pg2 pg2 nc 57 (b) pg1 pg1 pg1 nc 58 (b) pg0 pg0 pg0 nc 59 pd7 pd7 pd7 nc 60 pd6 pd6 pd6 nc 61 pd5 pd5 pd5 nc 62 pd4 pd4 pd4 nc 63 pd3 pd3 pd3 nc 64 pd2 pd2 pd2 nc 65 pd1 pd1 pd1 nc 66 pd0 pd0 pd0 nc 67 avss avss avss vss 68 p70/an0 p70/an0 p70/an0 nc 69 p71/an1 p71/an1 p71/an1 nc 70 p72/an2 p72/an2 p72/an2 nc 71 p73/an3 p73/an3 p73/an3 nc 72 p74/an4 p74/an4 p74/an4 nc 73 p75/an5 p75/an5 p75/an5 nc 74 p76/an6/da0 p76/an6/da0 p76/an6/da0 nc 75 p77/an7/da1 p77/an7/da1 p77/an7/da1 nc 76 avcc avcc avcc vcc 77 avref avref avref vcc 78 p60/ftci/cin0/ kin0 /hfbacki/ tmix p60/ftci/cin0/ kin0 /hfbacki/ tmix p60/ftci/cin0/ kin0 /hfbacki/ tmix nc 79 p61/ftoa/cin1/ kin1 /vsynco p61/ftoa/cin1/ kin1 /vsynco p61/ftoa/cin1/ kin1 /vsynco nc 80 p62/ftia/cin2/ kin2 /vsynci/tmiy p62/ftia/cin2/ kin2 /vsynci/tmiy p62/ftia/cin2/ kin2 /vsynci/tmiy nc
19 pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 81 p63/ftib/cin3/ kin3 /vfbacki p63/ftib/cin3/ kin3 /vfbacki p63/ftib/cin3/ kin3 /vfbacki nc 82 p64/ftic/cin4/ kin4 /clampo p64/ftic/cin4/ kin4 /clampo p64/ftic/cin4/ kin4 /clampo nc 83 p65/ftid/cin5/ kin5 p65/ftid/cin5/ kin5 p65/ftid/cin5/ kin5 nc 84 p66/ftob/cin6/ kin6 / irq6 p66/ftob/cin6/ kin6 /irq6 p66/ftob/cin6/ kin6 / irq6 nc 85 p67/tmox/cin7/ kin7 / irq7 p67/tmox/cin7/ kin7 / irq7 p67/tmox/cin7/ kin7 / irq7 vss 86 vcc vcc vcc vcc 87 pc7 pc7 pc7 nc 88 pc6 pc6 pc6 nc 89 pc5 pc5 pc5 nc 90 pc4 pc4 pc4 nc 91 pc3 pc3 pc3 nc 92 pc2 pc2 pc2 nc 93 pc1 pc1 pc1 nc 94 pc0 pc0 pc0 nc 95 vss vss vss vss 96 a15 p27/a15/pw15/ cblank p27/pw15/cblank ce 97 a14 p26/a14/pw14 p26/pw14 fa14 98 a13 p25/a13/pw13 p25/pw13 fa13 99 a12 p24/a12/pw12 p24/pw12 fa12 100 a11 p23/a11/pw11 p23/pw11 fa11 101 a10 p22/a10/pw10 p22/pw10 fa10 102 a9 p21/a9/pw9 p21/pw9 oe 103 a8 p20/a8/pw8 p20/pw8 fa8 104 a7 p17/a7/pw7 p17/pw7 fa7 105 a6 p16/a6/pw6 p16/pw6 fa6 106 a5 p15/a5/pw5 p15/pw5 fa5 107 a4 p14/a4/pw4 p14/pw4 fa4
20 pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 108 a3 p13/a3/pw3 p13/pw3 fa3 109 a2 p12/a2/pw2 p12/pw2 fa2 110 a1 p11/a1/pw1 p11/pw1 fa1 111 vss vss vss vss 112 a0 p10/a0/pw0 p10/pw0 fa0 113 pb7/d7/ wue7 pb7/d7/ wue7 pb7/ wue7 nc 114 pb6/d6/ wue6 pb6/d6/ wue6 pb6/ wue6 nc 115 pb5/d5/ wue5 pb5/d5/ wue5 pb5/ wue5 nc 116 pb4/d4/ wue4 pb4/d4/ wue4 pb4/ wue4 nc 117 pb3/d3/ wue3 pb3/d3/ wue3 pb3/ wue3 /cs4 nc 118 pb2/d2/ wue2 pb2/d2/ wue2 pb2/ wue2 /cs3 nc 119 pb1/d1/ wue1 pb1/d1/ wue1 pb1/hirq4/ wue1 / lsci nc 120 pb0/d0/ wue0 pb0/d0/ wue0 pb0/hirq3/ wue0 / lsmi nc 121 d8 d8 p30/hdb0/lad0 fo0 122 d9 d9 p31/hdb1/lad1 fo1 123 d10 d10 p32/hdb2/lad2 fo2 124 d11 d11 p33/hdb3/lad3 fo3 125 d12 d12 p34/hdb4/ lframe fo4 126 d13 d13 p35/hdb5/ lreset fo5 127 d14 d14 p36/hdb6/lclk fo6 128 d15 d15 p37/hdb7/serirq fo7 129 p80 p80 p80/ha0/ pme nc 130 p81 p81 p81/ cs2 /ga20 nc 131 p82 p82 p82/hifsd/ clkrun nc 132 p83 p83 p83/ lpcpd nc 133 p84/ irq3 /txd1 p84/ irq3 /txd1 p84/ irq3 /txd1 nc 134 p85/ irq4 /rxd1 p85/ irq4 /rxd1 p85/ irq4 /rxd1 nc
21 pin name pin no. expanded modes single-chip modes flash memory tfp-144 mode 1 mode 2 (expe = 1) mode 3 (expe = 1) mode 2 (expe = 0) mode 3 (expe = 0) programmer mode 135 p86/ irq5 /sck1/ scl1 p86/ irq5 /sck1/ scl1 p86/ irq5 /sck1/ scl1 nc 136 p40/tmci0/txd2/ irtxd p40/tmci0/txd2/ irtxd p40/tmci0/txd2/ irtxd nc 137 p41/tmo0/rxd2/ irrxd p41/tmo0/rxd2/ irrxd p41/tmo0/rxd2/ irrxd nc 138 p42/tmri0/sck2/ sda1 p42/tmri0/sck2/ sda1 p42/tmri0/sck2/ sda1 nc 139 vss vss vss vss 140 x1 x1 x1 nc 141 x2 x2 x2 nc 142 reso reso reso nc 143 xtal xtal xtal xtal 144 extal extal extal extal
22 1.3.3 pin functions table 1.3 summarizes the functions of the h8s/2149 and h8s/2169 pins. table 1.3 pin functions pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function power vcc 59 1, 86 input power: for connection to the power supply. connect the vcc pin to the system power supply. vcl 9 13 input power supply stabilization capacitance: connect the vcl pin to the system power supply together with the vcc pin. vccb 4 36 input input/output buffer power: the power supply for the port a, e, f, and g input/output buffer. vss 15, 70, 71, 92 7, 42, 95, 111, 139 input ground: for connection to the power supply (0 v). connect all vss pins to the system power supply (0 v). clock xtal 2 143 input connected to a crystal oscillator. see section 23, clock pulse generator, for typical connection diagrams for a crystal oscillator and external clock input. extal 3 144 input connected to a crystal oscillator. the extal pin can also input an external clock. see section 23, clock pulse generator, for typical connection diagrams for a crystal oscillator and external clock input. 17 output system clock: supplies the system clock to external devices. excl 17 18 input external subclock input: input a 32.768 khz external subclock. x1 140 input leave open. x2 141 input leave open.
23 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function operating mode control md1 md0 5 6 9 10 input mode pins: these pins set the operating mode. the relation between the settings of pins md1 and md0 and the operating mode is shown below. these pins should not be changed while the mcu is operating. md1 md0 operating mode description 0 1 mode 1 normal expanded mode with on-chip rom disabled 1 0 mode 2 advanced expanded mode with on-chip rom enabled or single- chip mode 1 1 mode 3 normal expanded mode with on-chip rom enabled or single- chip mode system control res 1 8 input reset input: when this pin is driven low, the chip is reset. reso 100 142 output reset output: outputs reset signal to external device. stby 8 12 input standby: when this pin is driven low, a transition is made to hardware standby mode. address bus a23 to a16 10, 11, 20, 21, 30, 31, 47, 48 33, 34, 35, 37, 38, 39, 40, 41 output address bus (advanced): outputs address when 16-mbyte space is used. a15 to a0 60?7, 72?9 96-110, 112 output address bus: these pins output an address.
24 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function data bus d15 to d8 89?2 128-121 input/ output data bus (upper): bidirectional data bus. used for 8-bit data and upper byte of 16-bit data. d7 to d0 57, 58, 68, 69, 80, 81, 90, 91 113-130 input/ output data bus (lower): bidirectional data bus. used for lower byte of 16-bit data. bus control wait 16 17 input wait: requests insertion of a wait state in the bus cycle when accessing external 3- state address space. rd 22 21 output read: when this pin is low, it indicates that the external address space is being read. hwr 19 20 output high write: when this pin is low, it indicates that the external address space is being written to. the upper half of the data bus is valid. lwr 25 24 output low write: when this pin is low, it indicates that the external address space is being written to. the lower half of the data bus is valid. as / ios 18 19 output address strobe: when this pin is low, it indicates that address output on the address bus is valid. interrupt signals nmi 7 11 input nonmaskable interrupt: requests a nonmaskable interrupt. irq0 to irq7 23?5, 97?9, 34, 35 22-24, 133-135, 84, 85 input interrupt request 0 to 7: these pins request a maskable interrupt. 16-bit free- running ftci 26 78 input frt counter clock input: input pin for an external clock signal for the free-running counter (frc). timer (frt) ftoa 27 79 output frt output compare a output: the output compare a output pin. ftob 34 84 output frt output compare b output: the output compare b output pin. ftia 28 80 input frt input capture a input: the input capture a input pin.
25 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function 16-bit free- ftib 29 81 input frt input capture b input: the input capture b input pin. running timer ftic 32 82 input frt input capture c input: the input capture c input pin. (frt) ftid 33 83 input frt input capture d input: the input capture d input pin. 8-bit timer (tmr0, tmr1, tmo0 tmo1 tmox 50 53 35 137 3 85 output compare-match output: tmr0, tmr1, and tmrx compare-match output pins. tmrx, tmry) tmci0 tmci1 49 52 136 2 input counter external clock input: input pins for the external clock input to the tmr0 and tmr1 counters. tmri0 tmri1 51 54 138 4 input counter external reset input: tmr0 and tmr1 counter reset input pins. tmix tmiy 26 28 78 80 input counter external clock input/reset input: dual function as tmrx and tmry counter clock input pin and reset input pin. pwm timer (pwm) pw15 to pw0 60?7, 72?9 96-110, 112 output pwm timer output: pwm timer pulse output pins. 14-bit pwm timer (pwmx) pwx0 pwx1 55 56 5 6 output pwmx timer output: pwm d/a pulse output pins. serial communi- cation txd0 txd1 txd2 14 97 49 16 133 136 output transmit data: data output pins. interface (sci0, sci1, rxd0 rxd1 rxd2 13 98 50 15 134 137 input receive data: data input pins. sci2) sck0 sck1 sck2 12 99 51 14 135 138 input/ ouput serial clock: clock input/output pins. the sck0 output type is nmos push-pull. sci with irda (sci2) irtxd 49 136 output irda transmit data/receive data: input and output pins for data encoded for irda use. irrxd 50 137 input
26 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function keyboard buffer controller ps2ac ps2bc ps2cc 31 21 11 39 37 34 input/ ouput ps2 clock: keyboard buffer controller synchronization clock input/output pins. (ps2) ps2ad ps2bd ps2cd 30 20 10 38 35 33 input/ ouput ps2 data: keyboard buffer controller data input/output pins. host interface hdb7 to hdb0 89?2 128-121 input/ ouput host interface data bus: bidirectional 8-bit bus for accessing the host interface (xbs). (hif:xbs) cs1 , cs2 ecs2 , cs3 , cs4 18, 94, 25, 81, 80 19, 130, 24, 118, 117 input chip select 1, 2, 3, 4: input pins for selecting host interface (xbs) channel 1 to 4. ior 22 21 input i/o read: input pin that enables reading from the host interface (xbs). iow 19 20 input i/o write: input pin that enables writing to the host interface (xbs). ha0 93 129 input command/data: input pin that indicates whether an access is a data access or command access. ga20 94 130 output gate a20: a20 gate control signal output pin. hirq11 hirq1 hirq12 hirq3 hirq4 52 53 54 91 90 2 3 4 120 119 output host interrupt 11, 1, 12, 3, 4: output pins for interrupt requests to the host. hifsd 95 131 input host interface shutdown: control input pin used to place host interface (xbs) input/output pins in the high-impedance / cutoff state. host interface lad3 to lad0 85?2 124-121 input/ ouput address/data: lpc command, address, and data input/output pins. (hif:lpc) lframe 86 125 input lpc frame: input pin that indicates the start of an lpc cycle or forced termination of an abnormal lpc cycle. lreset 87 126 input lpc reset: input pin that indicates an lpc reset. lclk 88 127 input lpc clock: the lpc clock input pin.
27 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function host interface (hif:lpc) serirq 89 128 input/ ouput serial host interrupt: input/output pin for lpc serialized host interrupts (hirq1, hirq6, hirq9 to hirq12). lsci, lsmi , pme 90, 91, 93 119, 120, 129 input/ ouput lsci, lsmi, power management event: lpc auxiliary output pins. functionally, they are general i/o ports. ga20 94 130 input/ ouput gate a20: a20 gate control signal output pin. output state monitoring input is possible. clkrun 95 131 input/ ouput lclk clock run: input/output pin that requests the start of lclk operation when lclk is stopped. lpcpd 96 132 input lpc power-down: input pin that controls lpc module shutdown. keyboard control kin0 to kin15 26?9, 32?5, 48, 47, 31, 30, 21, 20, 11, 10 78-85, 41-37, 35-33 input keyboard input: matrix keyboard input pins. p10 to p17 and p20 to p27 are used as key-scan outputs. this allows a maximum 16-output 16-input, 256-key matrix to be configured. wue0 to wue7 91, 90, 81, 80, 69, 68, 58, 57 120-113 input wakeup event input: wakeup event input pins. these pins have a similar function to the keyboard input pins, and allow the same kind of wakeup as key-wakeup from various sources. a/d converter (adc) an7 to an0 45?8 68-75 input analog input: a/d converter analog input pins. cin0 to cin15 26?9, 32?5, 48, 47, 31, 30, 21, 20, 11, 10 78-85, 41-37, 35-33 input expansion a/d input: expansion a/d input pins can be connected to the a/d converter, but since they are also used as digital input/output pins, precision will fall. adtrg 25 24 input a/d conversion external trigger input: pin for input of an external trigger to start a/d conversion. d/a converter (dac) da0 da1 44 45 74 75 output analog output: d/a converter analog output pins.
28 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function a/d converter d/a converter avcc 37 76 input analog power: the analog power supply pin for the a/d converter and d/a converter. when the a/d and d/a converters are not used, this pin should be connected to the system power supply (+5 v or +3 v). avref 36 77 input analog reference voltage: the reference power supply pin for the a/d converter and d/a converter. when the a/d and d/a converters are not used, this pin should be connected to the system power supply (+5 v or +3 v). avss 46 67 input analog ground: the ground pin for the a/d converter and d/a converter. this pin should be connected to the system power supply (0 v). timer connec- tion vsynci hsynci csynci vfbacki hfbacki 28 52 54 29 26 80 2 4 81 78 input timer connection input: timer connection synchronous signal input pins. vsynco hsynco clampo cblank 27 53 32 60 79 3 82 96 output timer connection output: timer connection synchronous signal output pins. i 2 c bus interface (iic) scl0 scl1 12 99 14 135 input/ output i 2 c clock input/output (channels 0 and 1): i 2 c clock i/o pins. these pins have a bus drive function. the scl0 output type is nmos open- drain. sda0 sda1 16 51 17 138 input/ output i 2 c data input/output (channels 0 and 1): i 2 c data i/o pins. these pins have a bus drive function. the sda0 output type is nmos open- drain. i/o ports p17?10 72?9 104-110, 112 input/ output port 1: eight input/output pins. the data direction of each pin can be selected in the port 1 data direction register (p1ddr). these pins have built-in mos input pull- ups, and also have led drive capability.
29 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function i/o ports p27?20 60?7 96-103 input/ output port 2: eight input/output pins. the data direction of each pin can be selected in the port 2 data direction register (p2ddr). these pins have built-in mos input pull- ups, and also have led drive capability. p37?30 89?2 128-121 input/ output port 3: eight input/output pins. the data direction of each pin can be selected in the port 3 data direction register (p3ddr). these pins have built-in mos input pull- ups, and also have led drive capability. p47?40 56?9 6-2, 138-136 input/ output port 4: eight input/output pins. the data direction of each pin can be selected in the port 4 data direction register (p4ddr). p52?50 12?4 14-16 input/ output port 5: three input/output pins. the data direction of each pin can be selected in the port 5 data direction register (p5ddr). p52 is an nmos push-pull output. p67?60 35?2 29?6 85-78 input/ output port 6: eight input/output pins. the data direction of each pin can be selected in the port 6 data direction register (p6ddr). these pins have built-in mos input pull- ups. p77?70 45?8 75-68 input port 7: eight input pins. p86?80 99?3 135-129 input/ output port 8: seven input/output pins. the data direction of each pin can be selected in the port 8 data direction register (p8ddr). p97?90 16?9 22?5 17-24 input/ output port 9: eight input/output pins. the data direction of each pin (except p96) can be selected in the port 9 data direction register (p9ddr). p97 is an nmos push-pull output. pa7?a0 10, 11, 20, 21, 30, 31, 47, 48 33-35, 37-41 input/ output port a: eight input/output pins. the data direction of each pin can be selected in the port a data direction register (paddr). these pins have built-in mos input pull- ups. these are vccb drive pins. pb7?b0 57, 58, 68, 69, 80, 81, 90, 91 113-120 input/ output port b: eight input/output pins. the data direction of each pin can be selected in the port b data direction register (pbddr). these pins have built-in mos input pull- ups.
30 pin no. type symbol fp-100b, tfp-100b tfp-144 i/o name and function i/o ports pc7?c0 87-94 input/ output port c: eight input/output pins. the data direction of each pin can be selected in the port c data direction register (pcddr). these pins have built-in mos input pull- ups. pd7?d0 59-66 input/ output port d: eight input/output pins. the data direction of each pin can be selected in the port d data direction register (pdddr). these pins have built-in mos input pull- ups. pe7?e0 25-32 input/ output port e: eight input/output pins. the data direction of each pin can be selected in the port e data direction register (peddr). these pins have built-in mos input pull- ups. these are vccb drive pins. pf7?f0 43-50 input/ output port f: eight input/output pins. the data direction of each pin can be selected in the port f data direction register (pfddr). these pins have built-in mos input pull- ups. these are vccb drive pins. pg7?g0 51-58 input/ output port g: eight input/output pins. the data direction of each pin can be selected in the port g data direction register (pgddr). these pins have built-in mos input pull- ups. these are vccb drive pins.
31 section 2 cpu 2.1 overview the h8s/2000 cpu is a high-speed central processing unit with an internal 32-bit architecture that is upward-compatible with the h8/300 and h8/300h cpus. the h8s/2000 cpu has sixteen 16-bit general registers, can address a 16-mbyte (architecturally 4-gbyte) linear address space, and is ideal for realtime control. 2.1.1 features the h8s/2000 cpu has the following features. ? upward-compatible with h8/300 and h8/300h cpus ? can execute h8/300 and h8/300h object programs ? general-register architecture ? sixteen 16-bit general registers (also usable as sixteen 8-bit registers or eight 32-bit registers) ? sixty-five basic instructions ? 8/16/32-bit arithmetic and logic instructions ? multiply and divide instructions ? powerful bit-manipulation instructions ? eight addressing modes ? register direct [rn] ? register indirect [@ern] ? register indirect with displacement [@(d:16,ern) or @(d:32,ern)] ? register indirect with post-increment or pre-decrement [@ern+ or @?rn] ? absolute address [@aa:8, @aa:16, @aa:24, or @aa:32] ? immediate [#xx:8, #xx:16, or #xx:32] ? program-counter relative [@(d:8,pc) or @(d:16,pc)] ? memory indirect [@@aa:8] ? 16-mbyte address space ? program: 16 mbytes ? data: 16 mbytes (4 gbytes architecturally)
32 ? high-speed operation ? all frequently-used instructions execute in one or two states ? maximum clock rate: 10 mhz ? 8/16/32-bit register-register add/subtract: 100 ns ? 8 8-bit register-register multiply: 1200 ns ? 16 8-bit register-register divide: 1200 ns ? 16 16-bit register-register multiply: 2000 ns ? 32 16-bit register-register divide: 2000 ns ? two cpu operating modes ? normal mode ? advanced mode ? power-down state ? transition to power-down state by sleep instruction ? cpu clock speed selection 2.1.2 differences between h8s/2600 cpu and h8s/2000 cpu the differences between the h8s/2600 cpu and the h8s/2000 cpu are shown below. ? register configuration the mac register is supported only by the h8s/2600 cpu. ? basic instructions the four instructions mac, clrmac, ldmac, and stmac are supported only by the h8s/2600 cpu. ? number of execution states the number of execution states of the mulxu and mulxs instructions differ as follows. number of execution states instruction mnemonic h8s/2600 h8s/2000 mulxu mulxu.b rs, rd 3 12 mulxu.w rs, erd 4 20 mulxs mulxs.b rs, rd 4 13 mulxs.w rs, erd 5 21 there are also differences in the address space, exr register functions, power-down state, etc., depending on the product.
33 2.1.3 differences from h8/300 cpu in comparison to the h8/300 cpu, the h8s/2000 cpu has the following enhancements. ? more general registers and control registers ? eight 16-bit extended registers, and one 8-bit control register, have been added. ? expanded address space ? normal mode supports the same 64-kbyte address space as the h8/300 cpu. ? advanced mode supports a maximum 16-mbyte address space. ? enhanced addressing ? the addressing modes have been enhanced to make effective use of the 16-mbyte address space. ? enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? signed multiply and divide instructions have been added. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. ? higher speed ? basic instructions execute twice as fast. 2.1.4 differences from h8/300h cpu in comparison to the h8/300h cpu, the h8s/2000 cpu has the following enhancements. ? additional control register ? one 8-bit control register has been added. ? enhanced instructions ? addressing modes of bit-manipulation instructions have been enhanced. ? two-bit shift instructions have been added. ? instructions for saving and restoring multiple registers have been added. ? a test and set instruction has been added. ? higher speed ? basic instructions execute twice as fast.
34 2.2 cpu operating modes the h8s/2000 cpu has two operating modes: normal and advanced. normal mode supports a maximum 64-kbyte address space. advanced mode supports a maximum 16-mbyte total address space (architecturally the maximum total address space is 4 gbytes, with a maximum of 16 mbytes for the program area and a maximum of 4 gbytes for the data area). the mode is selected by the mode pins of the microcontroller. cpu operating modes normal mode advanced mode maximum 64 kbytes for program and data areas combined maximum 16 mbytes for program and data areas combined figure 2.1 cpu operating modes (1) normal mode the exception vector table and stack have the same structure as in the h8/300 cpu. address space: a maximum address space of 64 kbytes can be accessed. extended registers (en): the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers. when en is used as a 16-bit register it can contain any value, even when the corresponding general register (rn) is used as an address register. if the general register is referenced in the register indirect addressing mode with pre-decrement (@?n) or post-increment (@rn+) and a carry or borrow occurs, however, the value in the corresponding extended register (en) will be affected. instruction set: all instructions and addressing modes can be used. only the lower 16 bits of effective addresses (ea) are valid.
35 exception vector table and memory indirect branch addresses: in normal mode the top area starting at h'0000 is allocated to the exception vector table. one branch address is stored per 16 bits. the configuration of the exception vector table in normal mode is shown in figure 2.2. for details of the exception vector table, see section 4, exception handling. h'0000 h'0001 h'0002 h'0003 h'0004 h'0005 h'0006 h'0007 h'0008 h'0009 h'000a h'000b reset exception vector exception vector 1 exception vector 2 exception vector table (reserved for system use) figure 2.2 exception vector table (normal mode) the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in normal mode the operand is a 16-bit word operand, providing a 16- bit branch address. branch addresses can be stored in the top area from h'0000 to h'00ff. note that this area is also used for the exception vector table.
36 stack structure: when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc and condition-code register (ccr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.3. the extended control register (exr) is not pushed onto the stack. for details, see section 4, exception handling. (a) subroutine branch (b) exception handling pc (16 bits) ccr ccr * pc (16 bits) sp note: * ignored when returning. sp figure 2.3 stack structure in normal mode (2) advanced mode address space: linear access is provided to a 16-mbyte maximum address space (architecturally a maximum 16-mbyte program area and a maximum 4-gbyte data area, with a maximum of 4 gbytes for program and data areas combined). extended registers (en): the extended registers (e0 to e7) can be used as 16-bit registers, or as the upper 16-bit segments of 32-bit registers or address registers. instruction set: all instructions and addressing modes can be used.
37 exception vector table and memory indirect branch addresses: in advanced mode the top area starting at h'00000000 is allocated to the exception vector table in units of 32 bits. in each 32 bits, the upper 8 bits are ignored and a branch address is stored in the lower 24 bits (figure 2.4). for details of the exception vector table, see section 4, exception handling. h'00000000 h'00000003 h'00000004 h'0000000b h'0000000c exception vector table reserved reset exception vector (reserved for system use) reserved exception vector 1 reserved h'00000010 h'00000008 h'00000007 figure 2.4 exception vector table (advanced mode) the memory indirect addressing mode (@@aa:8) employed in the jmp and jsr instructions uses an 8-bit absolute address included in the instruction code to specify a memory operand that contains a branch address. in advanced mode the operand is a 32-bit longword operand, providing a 32-bit branch address. the upper 8 bits of these 32 bits are a reserved area that is regarded as h'00. branch addresses can be stored in the area from h'00000000 to h'000000ff. note that the first part of this range is also the exception vector table.
38 stack structure: in advanced mode, when the program counter (pc) is pushed onto the stack in a subroutine call, and the pc and condition-code register (ccr) are pushed onto the stack in exception handling, they are stored as shown in figure 2.5. the extended control register (exr) is not pushed onto the stack. for details, see section 4, exception handling. (a) subroutine branch (b) exception handling pc (24 bits) ccr pc (24 bits) sp sp reserved figure 2.5 stack structure in advanced mode
39 2.3 address space figure 2.6 shows a memory map of the h8s/2000 cpu. the h8s/2000 cpu provides linear access to a maximum 64-kbyte address space in normal mode, and a maximum 16-mbyte (architecturally 4-gbyte) address space in advanced mode. (b) advanced mode h'0000 h'ffff h'00000000 h'ffffffff h'00ffffff (a) normal mode data area program area cannot be used by the h8s/2169 or h8s/2149 figure 2.6 memory map
40 2.4 register configuration 2.4.1 overview the cpu has the internal registers shown in figure 2.7. there are two types of registers: general registers and control registers. t i2 i1 i0 exr * 76543210 pc 23 0 15 07 07 0 e0 e1 e2 e3 e4 e5 e6 e7 r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l general registers (rn) and extended registers (en) control registers (cr) legend: stack pointer program counter extended control register trace bit interrupt mask bits condition-code register interrupt mask bit user bit or interrupt mask bit sp: pc: exr: t: i2 to i0: ccr: i: ui: note: * does not affect operation in the h8s/2169 or h8s/2149. er0 er1 er2 er3 er4 er5 er6 er7 (sp) i ui hunzvc ccr 76543210 half-carry flag user bit negative flag zero flag overflow flag carry flag h: u: n: z: v: c: figure 2.7 cpu registers
41 2.4.2 general registers the cpu has eight 32-bit general registers. these general registers are all functionally alike and can be used as both address registers and data registers. when a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. when the general registers are used as 32-bit registers or address registers, they are designated by the letters er (er0 to er7). the er registers divide into 16-bit general registers designated by the letters e (e0 to e7) and r (r0 to r7). these registers are functionally equivalent, providing a maximum of sixteen 16-bit registers. the e registers (e0 to e7) are also referred to as extended registers. the r registers divide into 8-bit general registers designated by the letters rh (r0h to r7h) and rl (r0l to r7l). these registers are functionally equivalent, providing a maximum of sixteen 8- bit registers. figure 2.8 illustrates the usage of the general registers. the usage of each register can be selected independently. ? address registers ? 32-bit registers ? 16-bit registers ? 8-bit registers er registers (er0 to er7) e registers (extended registers) (e0 to e7) r registers (r0 to r7) rh registers (r0h to r7h) rl registers (r0l to r7l) figure 2.8 usage of general registers general register er7 has the function of stack pointer (sp) in addition to its general-register function, and is used implicitly in exception handling and subroutine calls. figure 2.9 shows the stack.
42 free area stack area sp (er7) figure 2.9 stack 2.4.3 control registers the control registers are the 24-bit program counter (pc), 8-bit extended control register (exr), and 8-bit condition-code register (ccr). (1) program counter (pc): this 24-bit counter indicates the address of the next instruction the cpu will execute. the length of all cpu instructions is 2 bytes (one word), so the least significant pc bit is ignored. (when an instruction is fetched, the least significant pc bit is regarded as 0.) (2) extended control register (exr): an 8-bit register. in the h8s/2169 or h8s/2149, this register does not affect operation. bit 7?race bit (t): this bit is reserved. in the h8s/2169 or h8s/2149, this bit does not affect operation. bits 6 to 3?eserved: these bits are reserved. they are always read as 1. bits 2 to 0?nterrupt mask bits (i2 to i0): these bits are reserved. in the h8s/2169 or h8s/2149, these bits do not affect operation. (3) condition-code register (ccr): this 8-bit register contains internal cpu status information, including an interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. bit 7?nterrupt mask bit (i): masks interrupts other than nmi when set to 1. (nmi is accepted regardless of the i bit setting.) the i bit is set to 1 by hardware at the start of an exception- handling sequence. for details, refer to section 5, interrupt controller.
43 bit 6?ser bit or interrupt mask bit (ui): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. this bit can also be used as an interrupt mask bit. for details, refer to section 5, interrupt controller. bit 5?alf-carry flag (h): when the add.b, addx.b, sub.b, subx.b, cmp.b, or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and cleared to 0 otherwise. when the add.w, sub.w, cmp.w, or neg.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and cleared to 0 otherwise. when the add.l, sub.l, cmp.l, or neg.l instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 27, and cleared to 0 otherwise. bit 4?ser bit (u): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. bit 3?egative flag (n): stores the value of the most significant bit (sign bit) of data. bit 2?ero flag (z): set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data. bit 1?verflow flag (v): set to 1 when an arithmetic overflow occurs, and cleared to 0 otherwise. bit 0?arry flag (c): set to 1 when a carry occurs, and cleared to 0 otherwise. used by: ? add instructions, to indicate a carry ? subtract instructions, to indicate a borrow ? shift and rotate instructions, to store the carry the carry flag is also used as a bit accumulator by bit-manipulation instructions. some instructions leave some or all of the flag bits unchanged. for the action of each instruction on the flag bits, refer to appendix a.1, list of instructions. operations can be performed on the ccr bits by the ldc, stc, andc, orc, and xorc instructions. the n, z, v, and c flags are used as branching conditions for conditional branch (bcc) instructions. 2.4.4 initial register values reset exception handling loads the cpu's program counter (pc) from the vector table, clears the trace bit in exr to 0, and sets the interrupt mask bits in ccr and exr to 1. the other ccr bits and the general registers are not initialized. in particular, the stack pointer (er7) is not initialized. the stack pointer should therefore be initialized by an mov.l instruction executed immediately after a reset.
44 2.5 data formats the cpu can process 1-bit, 4-bit (bcd), 8-bit (byte), 16-bit (word), and 32-bit (longword) data. bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, ? 7) of byte operand data. the daa and das decimal-adjust instructions treat byte data as two digits of 4-bit bcd data. 2.5.1 general register data formats figure 2.10 shows the data formats in general registers. 76543210 don? care 70 don? care 76543210 43 70 70 don? care upper digit lower digit lsb msb lsb data type general register data format 1-bit data 1-bit data 4-bit bcd data 4-bit bcd data byte data byte data rnh rnl rnh rnl rnh rnl msb don? care upper digit lower digit 43 70 don? care 70 don? care 70 figure 2.10 general register data formats
45 0 msb lsb 15 word data word data rn en 0 lsb 15 16 msb 31 en rn general register er general register e general register r general register rh general register rl most significant bit least significant bit legend: ern: en: rn: rnh: rnl: msb: lsb: 0 msb lsb 15 longword data ern data type general register data format figure 2.10 general register data formats (cont)
46 2.5.2 memory data formats figure 2.11 shows the data formats in memory. the cpu can access word data and longword data in memory, but word or longword data must begin at an even address. if an attempt is made to access word or longword data at an odd address, no address error occurs but the least significant bit of the address is regarded as 0, so the access starts at the preceding address. this also applies to instruction fetches. 76543210 70 msb lsb msb lsb msb lsb data type data format 1-bit data byte data word data longword data address address l address l address 2m address 2m + 1 address 2n address 2n + 1 address 2n + 2 address 2n + 3 figure 2.11 memory data formats when er7 (sp) is used as an address register to access the stack, the operand size should be word size or longword size.
47 2.6 instruction set 2.6.1 overview the h8s/2000 cpu has 65 types of instructions. the instructions are classified by function in table 2.1. table 2.1 instruction classification function instructions size types data transfer mov bwl 5 pop * 1 , push * 1 wl ldm * 5 , stm * 5 l movfpe * 3 , movtpe * 3 b arithmetic add, sub, cmp, eg bwl 19 operations addx, subx, daa, das b inc, dec bwl adds, subs l mulxu, divxu, mulxs, divxs bw extu, exts wl tas * 4 b logic operations and, or, xor, not bwl 4 shift shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr bwl 8 bit manipulation bset, bclr, bnot, btst, bld, bild, bst, bist, band, biand, bor, bior, bxor, bixor b14 branch bcc * 2 , jmp, bsr, jsr, rts 5 system control trapa, rte, sleep, ldc, stc, andc, orc, xorc, nop 9 block data transfer eepmov 1 total: 65 types notes: b: byte size; w: word size; l: longword size. 1. pop.w rn and push.w rn are identical to mov.w @sp+, rn and mov.w rn, @-sp. pop.l ern and push.l ern are identical to mov.l @sp+, ern and mov.l ern, @-sp. 2. bcc is the general name for conditional branch instructions. 3. cannot be used in the h8s/2169 or h8s/2149. 4. only register er0, er1, er4, or er5 should be used when using the tas instruction. 5. only registers er0 to er6 should be used when using the stm/ldm instruction.
48 2.6.2 instructions and addressing modes table 2.2 indicates the combinations of instructions and addressing modes that the h8s/2000 cpu can use. table 2.2 combinations of instructions and addressing modes addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:32,ern) @?rn/@ern+ @aa:8 @aa:16 @aa:24 @aa:32 @(d:8,pc) @(d:16,pc) @@aa:8 data mov bwl bwl bwl bwl bwl bwl b bwl bwl transfer pop, push wl ldm * 3 , stm * 3 l movfpe * 1 , movtpe * 1 b arithmetic add, cmp bwl bwl operations sub wlbwl addx, subx b b adds, subs l inc, dec bwl daa, das b mulxu, divxu bw mulxs, divxs bw neg bwl extu, exts wl tas * 2 b logic operations and, or, xor bwlbwl not bwl shift bwl bit manipulation b b b b b branch bcc, bsr jmp, jsr rts
49 addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:32,ern) @?rn/@ern+ @aa:8 @aa:16 @aa:24 @aa:32 @(d:8,pc) @(d:16,pc) @@aa:8 system trapa control rte sleep ldc b b wwwwww stc b wwwwww andc, orc, xorc b nop block data transfer bw legend: b: byte w: word l: longword notes: 1. cannot be used in the h8s/2169 or h8s/2149. 2. only register er0, er1, er4, or er5 should be used when using the tas instruction. 3. only registers er0 to er6 should be used when using the stm/ldm instruction.
50 2.6.3 table of instructions classified by function table 2.3 summarizes the instructions in each functional category. the notation used in table 2.3 is defined below. operation notation rd general register (destination) * rs general register (source) * rn general register * ern general register (32-bit register) (ead) destination operand (eas) source operand exr extended control register ccr condition-code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition subtraction multiplication division logical and logical or logical exclusive or move not (logical complement) :8/:16/:24/:32 8-, 16-, 24-, or 32-bit length note: * general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit registers (er0 to er7).
51 table 2.3 instructions classified by function type instruction size * 1 function data transfer mov b/w/l (eas) rd, rs (ead) moves data between two general registers or between a general register and memory, or moves immediate data to a general register. movfpe b cannot be used in the h8s/2169 or h8s/2149. movtpe b cannot be used in the h8s/2169 or h8s/2149. pop w/l @sp+ rn pops a general register from the stack. pop.w rn is identical to mov.w @sp+, rn. pop.l ern is identical to mov.l @sp+, ern. push w/l rn @?p pushes a general register onto the stack. push.w rn is identical to mov.w rn, @?p. push.l ern is identical to mov.l ern, @?p. ldm * 3 l @sp+ rn (register list) pops two or more general registers from the stack. stm * 3 l rn (register list) @?p pushes two or more general registers onto the stack. arithmetic operations add sub b/w/l rd rs rd, rd #imm rd performs addition or subtraction on data in two general registers, or on immediate data and data in a general register. (immediate byte data cannot be subtracted from byte data in a general register. use the subx or add instruction.) addx subx b rd rs c rd, rd #imm c rd performs addition or subtraction with carry on byte data in two general registers, or on immediate data and data in a general register. inc dec b/w/l rd 1 rd, rd 2 rd increments or decrements a general register by 1 or 2. (byte operands can be incremented or decremented by 1 only.) adds subs l rd 1 rd, rd 2 rd, rd 4 rd adds or subtracts the value 1, 2, or 4 to or from data in a 32-bit register. daa das b rd decimal adjust rd decimal-adjusts an addition or subtraction result in a general register by referring to the ccr to produce 4-bit bcd data.
52 type instruction size * 1 function arithmetic operations mulxu b/w rd rs rd performs unsigned multiplication on data in two general registers: either 8 bits 8 bits 16 bits or 16 bits 16 bits 32 bits. mulxs b/w rd rs rd performs signed multiplication on data in two general registers: either 8 bits 8 bits 16 bits or 16 bits 16 bits 32 bits. divxu b/w rd rs rd performs unsigned division on data in two general registers: either 16 bits 8 bits 8-bit quotient and 8-bit remainder or 32 bits 16 bits 16-bit quotient and 16- bit remainder. divxs b/w rd rs rd performs signed division on data in two general registers: either 16 bits 8 bits 8-bit quotient and 8-bit remainder or 32 bits 16 bits 16-bit quotient and 16- bit remainder. cmp b/w/l rd ?rs, rd ?#imm compares data in a general register with data in another general register or with immediate data, and sets ccr bits according to the result. neg b/w/l 0 ?rd rd takes the two's complement (arithmetic complement) of data in a general register. extu w/l rd (zero extension) rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by padding with zeros on the left. exts w/l rd (sign extension) rd extends the lower 8 bits of a 16-bit register to word size, or the lower 16 bits of a 32-bit register to longword size, by extending the sign bit. tas b @erd ?0, 1 ( of @erd) * 2 tests memory contents, and sets the most significant bit (bit 7) to 1.
53 type instruction size * 1 function logic operations and b/w/l rd rs rd, rd #imm rd performs a logical and operation on a general register and another general register or immediate data. or b/w/l rd rs rd, rd #imm rd performs a logical or operation on a general register and another general register or immediate data. xor b/w/l rd rs rd, rd #imm rd performs a logical exclusive or operation on a general register and another general register or immediate data. not b/w/l ?(rd) (rd) takes the one's complement (logical complement) of general register contents. shift operations shal shar b/w/l rd (shift) rd performs an arithmetic shift on general register contents. a 1-bit or 2-bit shift is possible. shll shlr b/w/l rd (shift) rd performs a logical shift on general register contents. a 1-bit or 2-bit shift is possible. rotl rotr b/w/l rd (rotate) rd rotates general register contents. 1-bit or 2-bit rotation is possible. rotxl rotxr b/w/l rd (rotate) rd rotates general register contents through the carry flag. 1-bit or 2-bit rotation is possible. bit- manipulation instructions bset b 1 ( of ) sets a specified bit in a general register or memory operand to 1. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bclr b 0 ( of ) clears a specified bit in a general register or memory operand to 0. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bnot b ( of ) ( of ) inverts a specified bit in a general register or memory operand. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. btst b ( of ) z tests a specified bit in a general register or memory operand and sets or clears the z flag accordingly. the bit number is specified by 3-bit immediate data or the lower three bits of a general register.
54 type instruction size * 1 function bit- manipulation instructions band b c ( of ) c ands the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. biand b c ?( of ) c ands the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data. bor b c ( of ) c ors the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. bior b c ?( of ) c ors the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data. bxor b c ( of ) c exclusive-ors the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. bixor b c ?( of ) c exclusive-ors the carry flag with the inverse of a specified bit in a general register or memory operand and stores the result in the carry flag. the bit number is specified by 3-bit immediate data. bld b ( of ) c transfers a specified bit in a general register or memory operand to the carry flag. bild b ( of ) c transfers the inverse of a specified bit in a general register or memory operand to the carry flag. the bit number is specified by 3-bit immediate data. bst b c ( of ) transfers the carry flag value to a specified bit in a general register or memory operand. bist b c ( of ) transfers the inverse of the carry flag value to a specified bit in a general register or memory operand. the bit number is specified by 3-bit immediate data.
55 type instruction size * 1 function branch instructions bcc branches to a specified address if a specified condition is true. the branching conditions are listed below. mnemonic description condition bra(bt) always (true) always brn(bf) never (false) never bhi high c z = 0 bls low or same c z = 1 bcc(bhs) carry clear (high or same) c = 0 bcs(blo) carry set (low) c = 1 bne not equal z = 0 beq equal z = 1 bvc overflow clear v = 0 bvs overflow set v = 1 bpl plus n = 0 bmi minus n = 1 bge greater or equal n v = 0 blt less than n v = 1 bgt greater than z (n ? v) = 0 ble less or equal z (n v) = 1 jmp branches unconditionally to a specified address. bsr branches to a subroutine at a specified address. jsr branches to a subroutine at a specified address. rts returns from a subroutine system control trapa starts trap-instruction exception handling. instructions rte returns from an exception-handling routine. sleep causes a transition to a power-down state.
56 type instruction size * 1 function system control instructions ldc b/w (eas) ccr, (eas) exr moves contents of a general register or memory or immediate data to ccr or exr. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. stc b/w ccr (ead), exr (ead) transfers ccr or exr contents to a general register or memory. although ccr and exr are 8-bit registers, word-size transfers are performed between them and memory. the upper 8 bits are valid. andc b ccr #imm ccr, exr #imm exr logically ands the ccr or exr contents with immediate data. orc b ccr #imm ccr, exr #imm exr logically ors the ccr or exr contents with immediate data. xorc b ccr #imm ccr, exr #imm exr logically exclusive-ors the ccr or exr contents with immediate data. nop pc + 2 pc only increments the program counter. block data transfer instructions eepmov.b eepmov.w if r4l 0 then repeat @er5+ @er6+ r4l? r4l until r4l = 0 else next; if r4 0 then repeat @er5+ @er6+ r4? r4 until r4 = 0 else next; block transfer instruction. transfers the number of data bytes specified by r4l or r4 from locations starting at the address indicated by er5 to locations starting at the address indicated by er6. after the transfer, the next instruction is executed. notes: 1. size refers to the operand size. b: byte w: word l: longword 2. only register er0, er1, er4, or er5 should be used when using the tas instruction. 3. only registers er0 to er6 should be used when using the stm/ldm instruction.
57 2.6.4 basic instruction formats the cpu instructions consist of 2-byte (1-word) units. an instruction consists of an operation field (op field), a register field (r field), an effective address extension (ea field), and a condition field (cc). operation field: indicates the function of the instruction, the addressing mode, and the operation to be carried out on the operand. the operation field always includes the first four bits of the instruction. some instructions have two operation fields. register field: specifies a general register. address registers are specified by 3 bits, data registers by 3 bits or 4 bits. some instructions have two register fields. some have no register field. effective address extension: eight, 16, or 32 bits specifying immediate data, an absolute address, or a displacement. condition field: specifies the branching condition of bcc instructions. figure 2.12 shows examples of instruction formats. op op rn rm nop, rts, etc. add.b rn, rm, etc. mov.b @(d:16, rn), rm, etc. (1) operation field only (2) operation field and register fields (3) operation field, register fields, and effective address extension rn rm op ea (disp) (4) operation field, effective address extension, and condition field op cc ea (disp) bra d:16, etc figure 2.12 instruction formats (examples)
58 2.6.5 notes on use of bit-manipulation instructions the bset, bclr, bnot, bst, and bist instructions read a byte of data, carry out bit manipulation, then write back the byte of data. caution is therefore required when using these instructions on a register containing write-only bits, or a port. the bclr instruction can be used to clear internal i/o register flags to 0. in this case, the relevant flag need not be read beforehand if it is clear that it has been set to 1 in an interrupt handling routine, etc. 2.7 addressing modes and effective address calculation 2.7.1 addressing mode the cpu supports the eight addressing modes listed in table 2.4. each instruction uses a subset of these addressing modes. arithmetic and logic instructions can use the register direct and immediate modes. data transfer instructions can use all addressing modes except program-counter relative and memory indirect. bit-manipulation instructions use register direct, register indirect, or absolute addressing mode to specify an operand, and register direct (bset, bclr, bnot, and btst instructions) or immediate (3-bit) addressing mode to specify a bit number in the operand. table 2.4 addressing modes no. addressing mode symbol 1 register direct rn 2 register indirect @ern 3 register indirect with displacement @(d:16,ern)/@(d:32,ern) 4 register indirect with post-increment register indirect with pre-decrement @ern+ @?rn 5 absolute address @aa:8/@aa:16/@aa:24/@aa:32 6 immediate #xx:8/#xx:16/#xx:32 7 program-counter relative @(d:8,pc)/@(d:16,pc) 8 memory indirect @@aa:8 register direct?n: the register field of the instruction code specifies an 8-, 16-, or 32-bit general register containing the operand. r0h to r7h and r0l to r7l can be specified as 8-bit registers. r0 to r7 and e0 to e7 can be specified as 16-bit registers. er0 to er7 can be specified as 32-bit registers.
59 register indirect?ern: the register field of the instruction code specifies an address register (ern) which contains the address of the operand in memory. if the address is a program instruction address, the lower 24 bits are valid and the upper 8 bits are all assumed to be 0 (h'00). register indirect with displacement?(d:16, ern) or @(d:32, ern): a 16-bit or 32-bit displacement contained in the instruction is added to an address register (ern) specified by the register field of the instruction, and the sum gives the address of a memory operand. a 16-bit displacement is sign-extended when added. register indirect with post-increment or pre-decrement?ern+ or @-ern: ? register indirect with post-increment?ern+ the register field of the instruction code specifies an address register (ern) which contains the address of a memory operand. after the operand is accessed, 1, 2, or 4 is added to the address register contents and the sum is stored in the address register. the value added is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the register value should be even. ? register indirect with pre-decrement?-ern the value 1, 2, or 4 is subtracted from an address register (ern) specified by the register field in the instruction code, and the result becomes the address of a memory operand. the result is also stored in the address register. the value subtracted is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the register value should be even. absolute address?aa:8, @aa:16, @aa:24, or @aa:32: the instruction code contains the absolute address of a memory operand. the absolute address may be 8 bits long (@aa:8), 16 bits long (@aa:16), 24 bits long (@aa:24), or 32 bits long (@aa:32). to access data, the absolute address should be 8 bits (@aa:8), 16 bits (@aa:16), or 32 bits (@aa:32) long. for an 8-bit absolute address, the upper 24 bits are all assumed to be 1 (h'ffff). for a 16-bit absolute address the upper 16 bits are a sign extension. a 32-bit absolute address can access the entire address space. a 24-bit absolute address (@aa:24) indicates the address of a program instruction. the upper 8 bits are all assumed to be 0 (h'00).
60 table 2.5 indicates the accessible absolute address ranges. table 2.5 absolute address access ranges absolute address normal mode advanced mode data address 8 bits (@aa:8) h'ff00 to h'ffff h'ffff00 to h'ffffff 16 bits (@aa:16) h'0000 to h'ffff h'000000 to h'007fff, h'ff8000 to h'ffffff 32 bits (@aa:32) h'000000 to h'ffffff program instruction address 24 bits (@aa:24) immediate?xx:8, #xx:16, or #xx:32: the instruction contains 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) immediate data as an operand. the adds, subs, inc, and dec instructions contain immediate data implicitly. some bit manipulation instructions contain 3-bit immediate data in the instruction code, specifying a bit number. the trapa instruction contains 2-bit immediate data in its instruction code, specifying a vector address. program-counter relative?(d:8, pc) or @(d:16, pc): this mode is used in the bcc and bsr instructions. an 8-bit or 16-bit displacement contained in the instruction is sign-extended and added to the 24-bit pc contents to generate a branch address. only the lower 24 bits of this branch address are valid; the upper 8 bits are all assumed to be 0 (h'00). the pc value to which the displacement is added is the address of the first byte of the next instruction, so the possible branching range is ?26 to +128 bytes (?3 to +64 words) or ?2766 to +32768 bytes (?6383 to +16384 words) from the branch instruction. the resulting value should be an even number. memory indirect?@aa:8: this mode can be used by the jmp and jsr instructions. the instruction code contains an 8-bit absolute address specifying a memory operand. this memory operand contains a branch address. the upper bits of the absolute address are all assumed to be 0, so the address range is 0 to 255 (h'0000 to h'00ff in normal mode, h'000000 to h'0000ff in advanced mode). in normal mode the memory operand is a word operand and the branch address is 16 bits long. in advanced mode the memory operand is a longword operand, the first byte of which is assumed to be all 0 (h'00). note that the first part of the address range is also the exception vector area. for further details, refer to section 4, exception handling.
61 ( a ) normal mode ( b ) advanced mode branch address specified by @aa:8 specified by @aa:8 reserved branch address figure 2.13 branch address specification in memory indirect mode if an odd address is specified in word or longword memory access, or as a branch address, the least significant bit is regarded as 0, causing data to be accessed or an instruction code to be fetched at the address preceding the specified address. (for further information, see section 2.5.2, memory data formats.) 2.7.2 effective address calculation table 2.6 indicates how effective addresses are calculated in each addressing mode. in normal mode the upper 8 bits of the effective address are ignored in order to generate a 16-bit address.
62 table 2.6 effective address calculation no. addressing mode and instruction format effective address calculation effective address (ea) 1 register direct (rn) op rm rn operand is general register contents. 2 register indirect (@ern) general register contents 31 0 31 0 r op 24 23 don? care 3 register indirect with displacement @(d:16, ern) or @(d:32, ern) general register contents sign extension disp 31 0 31 0 31 0 op r disp don? care 24 23 4 register indirect with post-increment or pre-decrement ? register indirect with post-increment @ern+ general register contents 1, 2, or 4 31 0 31 0 r op don? care 24 23 ? register indirect with pre-decrement @?rn general register contents 1, 2, or 4 byte word longword 1 2 4 operand size value added 31 0 31 0 op r don? care 24 23
63 no. addressing mode and instruction format effective address calculation effective address (ea) 5 absolute address @aa:8 @aa:16 @aa:32 31 0 8 7 @aa:24 31 0 16 15 31 0 31 0 op abs op abs abs op op abs h'ffff 24 23 don? care don? care don? care don? care 24 23 24 23 24 23 sign exten- sion 6 immediate #xx:8/#xx:16/#xx:32 op imm operand is immediate data. 7 program-counter relative @(d:8, pc)/@(d:16, pc) 0 0 23 23 disp 31 0 24 23 op disp pc contents don? care sign exten- sion
64 no. addressing mode and instruction format effective address calculation effective address (ea) 8 memory indirect @@aa:8 ? normal mode 0 0 31 8 7 0 15 h'000000 31 0 16 15 op abs abs memory contents h'00 24 23 don? care ? advanced mode 31 0 31 8 7 0 abs h'000000 31 0 24 23 op abs memory contents don? care
65 2.8 processing states 2.8.1 overview the cpu has five main processing states: the reset state, exception-handling state, program execution state, bus-released state, and power-down state. figure 2.14 shows a diagram of the processing states. figure 2.15 indicates the state transitions. reset state the cpu and all on-chip supporting modules have been initialized and are stopped. exception-handling state a transient state in which the cpu changes the normal processing flow in response to a reset, interrupt, or trap instruction. program execution state the cpu executes program instructions in sequence. bus-released state the external bus has been released in response to a bus request signal from a bus master other than the cpu. power-down state cpu operation is stopped to conserve power. * sleep mode software standby mode hardware standby mode processing states note: * the power-down state also includes a medium-speed mode, module stop mode, sub-active mode, sub-sleep mode, and watch mode. figure 2.14 processing states
66 end of bus request bus request program execution state bus-released state sleep mode exception-handling state external interrupt software standby mode res = high reset state stby = high, res = low hardware standby mode * 2 power-down state * 3 * 1 notes: 1. 2. 3. from any state except hardware standby mode, a transition to the reset state occurs whenever res goes low. a transition can also be made to the reset state when the watchdog timer overflows. from any state, a transition to hardware standby mode occurs when stby goes low. the power-down state also includes a watch mode, subactive mode, subsleep mode, etc. for details, refer to section 24, power-down state. sleep instruction with lson = 0, ssby = 0 interrupt request end of bus request bus request request for exception handling end of exception handling sleep instruction with lson = 0, pss = 0, ssby = 1 figure 2.15 state transitions 2.8.2 reset state when the res input goes low all current processing stops and the cpu enters the reset state. all interrupts are disabled in the reset state. reset exception handling starts when the res signal changes from low to high. the reset state can also be entered by a watchdog timer overflow. for details, refer to section 14, watchdog timer.
67 2.8.3 exception-handling state the exception-handling state is a transient state that occurs when the cpu alters the normal processing flow due to a reset, interrupt, or trap instruction. the cpu fetches a start address (vector) from the exception vector table and branches to that address. types of exception handling and their priority: exception handling is performed for resets, interrupts, and trap instructions. table 2.7 indicates the types of exception handling and their priority. trap instruction exception handling is always accepted in the program execution state. exception handling and the stack structure depend on the interrupt control mode set in syscr. table 2.7 exception handling types and priority priority type of exception detection timing start of exception handling high reset synchronized with clock exception handling starts immediately after a low-to-high transition at the res pin, or when the watchdog timer overflows. interrupt end of instruction execution or end of exception-handling sequence * 1 when an interrupt is requested, exception handling starts at the end of the current instruction or current exception-handling sequence. low trap instruction when trapa instruction is executed exception handling starts when a trap (trapa) instruction is executed. * 2 notes: 1. interrupts are not detected at the end of the andc, orc, xorc, and ldc instructions, or immediately after reset exception handling. 2. trap instruction exception handling is always accepted in the program execution state. reset exception handling: after the res pin has gone low and the reset state has been entered, when res goes high again, reset exception handling starts. when reset exception handling starts the cpu fetches a start address (vector) from the exception vector table and starts program execution from that address. all interrupts, including nmi, are disabled during reset exception handling and after it ends. interrupt exception handling and trap instruction exception handling: when interrupt or trap-instruction exception handling begins, the cpu references the stack pointer (er7) and pushes the program counter and other control registers onto the stack. next, the cpu alters the settings of the interrupt mask bits in the control registers. then the cpu fetches a start address (vector) from the exception vector table and program execution starts from that start address.
68 figure 2.16 shows the stack after exception handling ends. note: * ignored when returning. ccr pc (24 bits) sp ccr ccr * pc (16 bits) sp normal mode advanced mode figure 2.16 stack structure after exception handling (examples) 2.8.4 program execution state in this state the cpu executes program instructions in sequence. 2.8.5 bus-released state this is a state in which the bus has been released in response to a bus request from a bus master other than the cpu. while the bus is released, all cpu internal operations are halted. there is one other bus master in addition to the cpu: the data transfer controller (dtc). for further details, refer to section 6, bus controller. 2.8.6 power-down state the power-down state includes both modes in which the cpu stops operating and modes in which the cpu does not stop. there are five modes in which the cpu stops operating: sleep mode, software standby mode, hardware standby mode, subsleep mode, and watch mode. there are also three other power-down modes: medium-speed mode, module stop mode, and subactive mode. in medium-speed mode, the cpu and other bus masters operate on a medium-speed clock. module stop mode permits halting of the operation of individual modules, other than the cpu. subactive mode, subsleep mode, and watch mode are power-down modes that use subclock input. for details, refer to section 24, power-down state.
69 sleep mode: a transition to sleep mode is made if the sleep instruction is executed while the software standby bit (ssby) in the standby control register (sbycr) and the lson bit in the low-power control register (lpwrcr) are both cleared to 0. in sleep mode, cpu operations stop immediately after execution of the sleep instruction. the contents of cpu registers are retained. software standby mode: a transition to software standby mode is made if the sleep instruction is executed while the ssby bit in sbycr is set to 1 and the lson bit in lpwrcr and the pss bit in the wdt1 timer control/status register (tcsr) are both cleared to 0. in software standby mode, the cpu and clock halt and all mcu operations stop. as long as a specified voltage is supplied, the contents of cpu registers and on-chip ram are retained. the i/o ports also remain in their existing states. hardware standby mode: a transition to hardware standby mode is made when the stby pin goes low. in hardware standby mode, the cpu and clock halt and all mcu operations stop. the on-chip supporting modules are reset, but as long as a specified voltage is supplied, on-chip ram contents are retained. 2.9 basic timing 2.9.1 overview the cpu is driven by a system clock, denoted by the symbol ?. the period from one rising edge of ? to the next is referred to as a state. the memory cycle or bus cycle consists of one, two, or three states. different methods are used to access on-chip memory, on-chip supporting modules, and the external address space. 2.9.2 on-chip memory (rom, ram) on-chip memory is accessed in one state. the data bus is 16 bits wide, permitting both byte and word transfer instruction. figure 2.17 shows the on-chip memory access cycle. figure 2.18 shows the pin states.
70 internal address bus internal read signal internal data bus internal write signal internal data bus bus cycle t1 address read data write data read access write access figure 2.17 on-chip memory access cycle bus cycle t1 unchanged address bus as rd hwr , lwr data bus ? high high high hi g h impedance figure 2.18 pin states during on-chip memory access
71 2.9.3 on-chip supporting module access timing (internal i/o register 1 and 2) the on-chip supporting modules (internal i/o register 1 and 2) are accessed in two states. the data bus is either 8 bits or 16 bits wide, depending on the particular internal i/o register being accessed. figure 2.19 shows the access timing for the on-chip supporting modules (internal i/o register 1 and 2). figure 2.20 shows the pin states. bus cycle t1 t2 address read data write data internal read signal internal data bus internal write signal internal data bus read access write access internal address bus figure 2.19 on-chip supporting module (internal i/o register 1 and 2)access cycle
72 bus cycle t1 t2 unchanged address bus as rd hwr , lwr data bus ? high high high high impedance figure 2.20 pin states during on-chip supporting module (internal i/o register 1 and 2) access
73 2.9.4 on-chip supporting module access timing (internal i/o register 3) the on-chip supporting modules (internal i/o register 3) are accessed in three states. the data bus is 8 bits wide. figure 2.21 shows the access timing fo the on-chip supporting modules (internal i/o register 3). figure 2.22 shows the pin states. internal address bus internal read signal internal data bus internal write signal internal data bus f bus cycle t1 address read access write access read data write data t2 t3 figure 2.21 on-chip supporting module (internal i/o register 3) access cycle bus cycle t1 as rd hwr , lwr data bus f t2 t3 high high high impedance high unchanged address bus figure 2.22 pin states during on-chip supporting module (internal i/o register 3) access
74 2.9.5 external address space access timing the external address space is accessed with an 8-bit or 16-bit data bus width in a two-state or three-state bus cycle. in three-state access, wait states can be inserted. for further details, refer to section 6, bus controller. 2.10 usage note 2.10.1 tas instruction only register er0, er1, er4, or er5 should be used when using the tas instruction. the tas instruction is not generated by the hitachi h8s and h8/300 series c/c++ compilers. if the tas instruction is used as a user-defined intrinsic function, ensure that only register er0, er1, er4, or er5 is used. 2.10.2 stm/ldm instruction er7 is not used as the register that can be saved (stm)/restored (ldm) when using stm/ldm instruction, because er7 is the stack pointer. two, three, or four registers can be saved/restored by one stm/ldm instruction. the following ranges can be specified in the register list. two registers: er0?r1, er2?r3, or er4?r5 three registers: er0?r2 or er4?r6 four registers: er0?r3 the stm/ldm instruction including er7 is not generated by the hitachi h8s and h8/300 series c/c++compilers.
75 section 3 mcu operating modes 3.1 overview 3.1.1 operating mode selection the h8s/2169 or h8s/2149 has three operating modes (modes 1 to 3). these modes enable selection of the cpu operating mode and enabling/disabling of on-chip rom, by setting the mode pins (md1 and md0). table 3.1 lists the mcu operating modes. table 3.1 mcu operating mode selection mcu operating mode md1 md0 cpu operating mode description on-chip rom 0 00 1 1 normal expanded mode with on-chip rom disabled disabled 2 1 0 advanced expanded mode with on-chip rom enabled single-chip mode enabled 3 1 normal expanded mode with on-chip rom enabled single-chip mode the cpu? architecture allows for 4 gbytes of address space, but the h8s/2169 or h8s/2149 actually access a maximum of 16 mbytes. mode 1 is an externally expanded mode that allows access to external memory and peripheral devices. with modes 2 and 3, operation begins in single-chip mode after reset release, but a transition can be made to external expansion mode by setting the expe bit in mdcr. the h8s/2169 or h8s/2149 can only be used in modes 1 to 3. these means that the mode pins must select one of these modes. do not changes the inputs at the mode pins during operation.
76 3.1.2 register configuration the h8s/2169 or h8s/2149 has a mode control register (mdcr) that indicates the inputs at the mode pins (md1 and md0), a system control register (syscr) and bus control register (bcr) that control the operation of the mcu, and a serial/timer control register (stcr) that controls the operation of the supporting modules. table 3.2 summarizes these registers. table 3.2 mcu registers name abbreviation r/w initial value address * mode control register mdcr r/w undetermined h'ffc5 system control register syscr r/w h'09 h'ffc4 bus control register bcr r/w h'd7 h'ffc6 serial/timer control register stcr r/w h'00 h'ffc3 note: * lower 16 bits of the address. 3.2 register descriptions 3.2.1 mode control register (mdcr) 7 expe * r/w * 6 0 5 0 4 0 3 0 0 mds0 * r 2 0 1 mds1 * r note: * determined by pins md1 and md0. bit initial value read/write mdcr is an 8-bit read-only register that indicates the operating mode setting and the current operating mode of the mcu. the expe bit is initialized in coordination with the mode pin states by a reset and in hardware standby mode.
77 bit 7?xpanded mode enable (expe): sets expanded mode. in mode 1, this bit is fixed at 1 and cannot be modified. in modes 2 and 3, this bit has an initial value of 0, and can be read and written. bit 7 expe description 0 single chip mode is selected 1 expanded mode is selected bits 6 to 2?eserved: these bits cannot be modified and are always read as 0. bits 1 and 0?ode select 1 and 0 (mds1, mds0): these bits indicate the input levels at pins md1 and md0 (the current operating mode). bits mds1 and mds0 correspond to md1 and md0. mds1 and mds0 are read-only bits?hey cannot be written to. the mode pin (md1 and md0) input levels are latched into these bits when mdcr is read. 3.2.2 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write syscr is an 8-bit readable/writable register that performs selection of system pin functions, reset source monitoring, interrupt control mode selection, nmi detected edge selection, supporting module pin location selection, supporting module register access control, and ram address space control. only bits 7, 6, 3, 1, and 0 are described here. for a detailed description of these bits, refer also to the description of the relevant modules (host interface, bus controller, watchdog timer, ram, etc.). for information on bits 5, 4, and 2, see section 5.2.1, system control register (syscr). syscr is initialized to h'09 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?hip select 2 enable (cs2e): specifies the location of the host interface control pin ( cs2 ). for details, see section 18a, host interface (xbs).
78 bit 6?os enable (iose): controls the function of the as / ios pin in expanded mode. bit 6 iose description 0 the as / ios pin functions as the address strobe pin (low output when accessing an external area) (initial value) 1 the as / ios pin functions as the i/o strobe pin (low output when accessing a specified address from h'(ff)f000 to h'(ff)f7ff) bit 3?xternal reset (xrst): indicates the reset source. when the watchdog timer is used, a reset can be generated by watchdog timer overflow as well as by external reset input. xrst is a read-only bit. it is set to 1 by an external reset and cleared to 0 by watchdog timer overflow. bit 3 xrst description 0 a reset is generated by watchdog timer overflow 1 a reset is generated by an external reset (initial value) bit 1?ost interface enable (hie): this bit controls cpu access to the host interface (hif:xbs) data registers and control registers (hicr, idr1, odr1, str1, idr2, odr2, and str2), the keyboard controller and mos input pull-up control registers (kmimr, kmpcr, and kmimra), the 8-bit timer (channel x and y) data registers and control registers (tcrx/tcry, tcsrx/tcsry, ticrr/tcoray, ticrf/tcorby, tcntx/tcnty, tcorc/tisr, tcorax, and tcorbx), and the timer connection control registers (tconri, tconro, tconrs, and sedgr). bit 1 hie description 0 in areas h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff, cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is permitted (initial value) 1 in areas h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff, cpu access to host interface data registers and control registers, and keyboard controller and mos input pull-up control registers, is permitted
79 bit 0?am enable (rame): enables or disables the on-chip ram. the rame bit is initialized when the reset state is released. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value) 3.2.3 bus control register (bcr) 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 1 r/w 1 ios1 1 r/w bit initial value read/write bcr is an 8-bit readable/writable register that specifies the external memory space access mode, and the i/o area range when the as pin is designated for use as the i/o strobe. for details on bits 7 to 2, see section 6.2.1, bus control register (bcr). bcr is initialized to h'd7 by a reset and in hardware standby mode. bits 1 and 0?ios select 1 and 0 (ios1, ios0): these bits specify the addresses for which the as / ios pin output goes low when iose = 1. bcr bit 1 bit 0 ios1 ios0 description 0 0 the as / ios pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f03f 1 the as / ios pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f0ff 1 0 the as / ios pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f3ff 1 the as / ios pin output goes low in accesses to addresses h'(ff)f000 to h'(ff)f7ff (initial value)
80 3.2.4 serial timer control register (stcr) 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 0 r/w 1 icks1 0 r/w bit initial value read/write stcr is an 8-bit readable/writable register that controls register?ccess, the iic operating mode (when the on-chip iic option is included), an on-chip flash memory control, and also selects the tcnt input clock. for details of functions other than register access control, see the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 5? 2 c control (iics, iicx1, iicx0): these bits control the operation of the i 2 c bus interface and others when the on-chip iic option is included. for details, see section 16, i 2 c bus interface. bit 4? 2 c master enable (iice): controls cpu access to the i 2 c bus interface data registers and control registers (iccr, icsr, icdr/sarx, and icmr/sar), the pwmx data registers and control registers (dadrah/dacr, dadral, dadrbh/dacnth, and dadrbl/dacntl), and the sci control registers (smr, brr, and scmr). bit 4 iice description 0 addresses h'(ff)ff88 and h'(ff)ff89, and h'(ff)ff8e and h'(ff)ff8f, are used for sci1 control register access addresses h'(ff)ffa0 and h'(ff)ffa1, and h'(ff)ffa6 and h'(ff)ffa7, are used for sci2 control register access addresses h'(ff)ffd8 and h'(ff)ffd9, and h'(ff)ffde and h'(ff)ffdf, are used for sci0 control register access (initial value) 1 addresses h'(ff)ff88 and h'(ff)ff89, and h'(ff)ff8e and h'(ff)ff8f, are used for iic1 data register and control register access addresses h'(ff)ffa0 and h'(ff)ffa1, and h'(ff)ffa6 and h'(ff)ffa7, are used for pwmx data register and control register access addresses h'(ff)ffd8 and h'(ff)ffd9, and h'(ff)ffde and h'(ff)ffdf, are used for iic0 data register and control register access
81 bit 3?lash memory control register enable (flshe): controls cpu access to the flash memory control registers (flmcr1, flmcr2, ebr1, and ebr2), the power-down mode control registers (sbycr, lpwrcr, mstpcrh, and mstpcrl), and the supporting module control register (pcsr and syscr2). bit 3 flshe description 0 addresses h'(ff)ff80 to h'(ff)ff87 are used for power-down mode control register and supporting module control register access (initial value) 1 addresses h'(ff)ff80 to h'(ff)ff87 are used for flash memory control register access bit 2?eserved: do not write 1 to this bit. bits 1 and 0?nternal clock select 1 and 0 (icks1, icks0): these bits, together with bits cks2 to cks0 in tcr, select the clock to be input to tcnt. for details, see section 12, 8-bit timers.
82 3.3 operating mode descriptions 3.3.1 mode 1 the cpu can access a 64-kbyte address space in normal mode. the on-chip rom is disabled. ports 1 and 2 function as an address bus, port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus. 3.3.2 mode 2 the cpu can access a 16-mbyte address space in advanced mode. the on-chip rom is enabled. after a reset, single-chip mode is set, and the expe bit in mdcr must be set to 1 in order to use external addresses. when the expe bit in mdcr is set to 1, ports 1, 2 and a function as input ports after a reset. they can be set to output addresses by setting the corresponding bits in the data direction register (ddr) to 1. port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus. 3.3.3 mode 3 the cpu can access a 64-kbyte address space in normal mode. the on-chip rom is enabled. after a reset, single-chip mode is set, and the expe bit in mdcr must be set to 1 in order to use external addresses. when the expe bit in mdcr is set to 1, ports 1 and 2 function as input ports after a reset. they can be set to output addresses by setting the corresponding bits in the data direction register (ddr) to 1. port 3 functions as a data bus, and part of port 9 carries bus control signals. clearing the abw bit to 0 in the wscr register makes port b a data bus. in this operating mode, the available amount of on-chip rom in products with 64 kbytes or more of rom is limited to 56 kbytes.
83 3.4 pin functions in each operating mode the pin functions of ports 1 to 3, 9, a, and b vary depending on the operating mode. table 3.3 shows their functions in each operating mode. table 3.3 pin functions in each mode port mode 1 mode 2 mode 3 port 1 a p * /a p * /a port 2 a p * /a p * /a port a p p * /a p port 3 d p * /d p * /d port b p * /d p * /d p * /d port 9 p97 p * /c p * /c p * /c p96 c * /p p * /c p * /c p95 to p93 c p * /c p * /c p92 to p91 p p p p90 p * /c p * /c p * /c port c to port g p p p legend: p: i/o port a: address bus output d: data bus i/o c: control signals, clock i/o * : after reset 3.5 memory map in each operating mode figure 3.1 shows memory maps for each of the operating modes. the address space is 64 kbytes in modes 1 and 3 (normal modes), and 16 mbytes in mode 2 (advanced mode). the on-chip rom capacity is 64 kbytes, but only 56 kbytes are available in mode 3 (normal mode). do not access reserved area. for details, see section 6, bus controller.
84 mode 3/expe = 0 (normal single-chip mode) h'0000 h'dfff h'0000 h'dfff h'0000 external address space on-chip rom on-chip rom mode 3/expe = 1 (normal expanded mode with on-chip rom enabled) mode 1 (normal expanded mode with on-chip rom disabled) h'efff h'e880 h'efff h'e880 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 internal i/o registers 2 on-chip ram * internal i/o registers 1 h'efff on-chip ram * on-chip ram h'e880 h'e080 h'e080 h'e080 h'feff h'ffff h'fe50 h'ff7f h'ff80 h'ff00 on-chip ram (128 bytes) * external address space internal i/o registers 3 h'fe4f h'f7ff h'f800 h'f000 internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) * external address space h'fe4f h'f7ff h'f800 h'f000 internal i/o registers 3 external address space internal i/o registers 2 internal i/o registers 1 on-chip ram (128 bytes) h'feff h'ffff h'fe50 internal i/o registers 3 reserved area * reserved area * reserved area h'fe4f h'f800 h'ff7f h'ff80 h'ff00 note: * external addresses can be accessed b y clearin g the rame bit in syscr to 0. figure 3.1 h8s/2169 or h8s/2149 memory map in each operating mode
85 h'01ffff h'020000 h'000000 h'01ffff h'00ffff h'00ffff h'000000 h'ffefff h'ffe080 h'fffeff h'ffffff h'fffe50 h'ffff7f h'ffff80 h'ffff00 h'ffefff h'ffe880 h'ffe880 h'ffe080 h'fffeff h'fffe50 h'fffe4f h'fff800 h'fff7ff h'fff000 h'fffe4f h'fff800 h'ffff7f h'ffff80 h'ffff00 h'ffffff mode 2/expe = 0 (advanced single-chip mode) on-chip rom external address space on-chip rom mode 2/expe = 1 (advanced expanded mode with on-chip rom enabled) internal i/o registers 2 on-chip ram * internal i/o registers 1 on-chip ram (128 bytes) * external address space internal i/o registers 2 internal i/o registers 3 internal i/o registers 3 reserved area * reserved area on-chip ram internal i/o registers 1 on-chip ram (128 bytes) reserved area reserved area note: * external addresses can be accessed b y clearin g the rame bit in syscr to 0. figure 3.1 h8s/2169 or h8s/2149 memory map in each operating mode (cont)
86
87 section 4 exception handling 4.1 overview 4.1.1 exception handling types and priority as table 4.1 indicates, exception handling may be caused by a reset, trap instruction, or interrupt. exception handling is prioritized as shown in table 4.1. if two or more exceptions occur simultaneously, they are accepted and processed in order of priority. trap instruction exceptions are accepted at all times in the program execution state. exception handling sources, the stack structure, and the operation of the cpu vary depending on the interrupt control mode set by the intm0 and intm1 bits in syscr. table 4.1 exception types and priority priority exception type start of exception handling high reset starts immediately after a low-to-high transition at the res pin, or when the watchdog timer overflows. trace * 1 starts when execution of the current instruction or exception handling ends, if the trace (t) bit is set to 1. interrupt starts when execution of the current instruction or exception handling ends, if an interrupt request has been issued. * 2 direct transition started by a direct transition resulting from execution of a sleep instruction. low trap instruction (trapa) * 3 started by execution of a trap instruction (trapa). notes: 1. traces are enabled only in interrupt control modes 2 and 3. (they cannot be used in the h8s/2169 or h8s/2149.) trace exception handling is not executed after execution of an rte instruction. 2. interrupt detection is not performed on completion of andc, orc, xorc, or ldc instruction execution, or on completion of reset exception handling. 3. trap instruction exception handling requests are accepted at all times in the program execution state.
88 4.1.2 exception handling operation exceptions originate from various sources. trap instructions and interrupts are handled as follows: 1. the program counter (pc) and condition-code register (ccr) are pushed onto the stack. 2. the interrupt mask bits are updated. the t bit is cleared to 0. 3. a vector address corresponding to the exception source is generated, and program execution starts from that address. for a reset exception, steps 2 and 3 above are carried out. 4.1.3 exception sources and vector table the exception sources are classified as shown in figure 4.1. different vector addresses are assigned to different exception sources. table 4.2 lists the exception sources and their vector addresses. exception sources reset trace interrupts direct transition trap instruction (cannot be used in the h8s/2169 or h8s/2149) external interrupts: nmi, irq7 to irq0 internal interrupts: interrupt sources in on-chip supporting modules figure 4.1 exception sources
89 table 4.2 exception vector table vector address * 1 exception source vector number normal mode advanced mode reset 0 h'0000 to h'0001 h'0000 to h'0003 reserved for system use 1 h'0002 to h'0003 h'0004 to h'0007 2 h'0004 to h'0005 h'0008 to h'000b 3 h'0006 to h'0007 h'000c to h'000f 4 h'0008 to h'0009 h'0010 to h'0013 5 h'000a to h'000b h'0014 to h'0017 direct transition 6 h'000c to h'000d h'0018 to h'001b external interrupt nmi 7 h'000e to h'000f h'001c to h'001f trap instruction (4 sources) 8 h'0010 to h'0011 h'0020 to h'0023 9 h'0012 to h'0013 h'0024 to h'0027 10 h'0014 to h'0015 h'0028 to h'002b 11 h'0016 to h'0017 h'002c to h'002f reserved for system use 12 h'0018 to h'0019 h'0030 to h'0033 13 h'001a to h'001b h'0034 to h'0037 14 h'001c to h'001d h'0038 to h'003b 15 h'001e to h'001f h'003c to h'003f external interrupt irq0 16 h'0020 to h'0021 h'0040 to h'0043 irq1 17 h'0022 to h'0023 h'0044 to h'0047 irq2 18 h'0024 to h'0025 h'0048 to h'004b irq3 19 h'0026 to h'0027 h'004c to h'004f irq4 20 h'0028 to h'0029 h'0050 to h'0053 irq5 21 h'002a to h'002b h'0054 to h'0057 irq6 22 h'002c to h'002d h'0058 to h'005b irq7 23 h'002e to h'002f h'005c to h'005f internal interrupt * 2 24 107 h'0030 to h'0031 h'00ce to h'00df h'0060 to h'0063 h'019c to h'01bf notes: 1. lower 16 bits of the address. 2. for details on internal interrupt vectors, see section 5.3.3, interrupt exception vector table.
90 4.2 reset 4.2.1 overview a reset has the highest exception priority. when the res pin goes low, all processing halts and the mcu enters the reset state. a reset initializes the internal state of the cpu and the registers of on-chip supporting modules. immediately after a reset, interrupt control mode 0 is set. reset exception handling begins when the res pin changes from low to high. the mcu can also be reset by overflow of the watchdog timer. for details, see section 14, watchdog timer. 4.2.2 reset sequence the mcu enters the reset state when the res pin goes low. to ensure that the chip is reset, hold the res pin low for at least 20 ms when powering on. to reset the chip during operation, hold the res pin low for at least 20 states. for pin states in a reset, see appendix d.1, pin states at reset. when the res pin goes high after being held low for the necessary time, the chip starts reset exception handling as follows: [1] the internal state of the cpu and the registers of the on-chip supporting modules are initialized, and the i bit is set to 1 in ccr. [2] the reset exception vector address is read and transferred to the pc, and program execution starts from the address indicated by the pc. figures 4.2 and 4.3 show examples of the reset sequence.
91 internal address bus internal read signal internal write signal internal data bus (1) (3) vector fetch internal processing fetch of first program instruction high (1) reset exception vector address ((1) = h'0000) (2) start address (contents of reset exception vector address) (3) start address ((3) = (2)) (4) first program instruction (2) (4) res figure 4.2 reset sequence (mode 3)
92 address bus vector fetch internal processing fetch of first program instruction (1) (3) reset exception vector address ((1) = h'0000, (3) = h'0001) (2) (4) start address (contents of reset exception vector address) (5) start address ((5) = (2) (4)) (6) first program instruction res (1) (5) high (2) (4) (3) (6) rd hwr , lwr d15 to d8 * note: * 3 program wait states are inserted. ** figure 4.3 reset sequence (mode 1) 4.2.3 interrupts after reset if an interrupt is accepted after a reset but before the stack pointer (sp) is initialized, the pc and ccr will not be saved correctly, leading to a program crash. to prevent this, all interrupt requests, including nmi, are disabled immediately after a reset. since the first instruction of a program is always executed immediately after the reset state ends, make sure that this instruction initializes the stack pointer (example: mov.l #xx:32, sp).
93 4.3 interrupts interrupt exception handling can be requested by nine external sources (nmi and irq7 to irq0) from 31 input pins (nmi, irq7 to irq0 , and kin15 to kin0 , wue7 to wue0 ), and internal sources in the on-chip supporting modules. figure 4.4 shows the interrupt sources and the number of interrupts of each type. the on-chip supporting modules that can request interrupts include the watchdog timer (wdt), 16-bit free-running timer (frt), 8-bit timer (tmr), serial communication interface (sci), data transfer controller (dtc), a/d converter (adc), host interface (hif:xbs, lpc), keyboard buffer controller (ps2), and i 2 c bus interface. each interrupt source has a separate vector address. nmi is the highest-priority interrupt. interrupts are controlled by the interrupt controller. the interrupt controller has two interrupt control modes and can assign interrupts other than nmi and address break to either three priority/mask levels to enable multiplexed interrupt control. for details on interrupts, see section 5, interrupt controller. interrupts external interrupts internal interrupts nmi (1) irq7 to irq0 (8) wdt * (2) frt (7) tmr (10) sci (12) dtc (1) adc (1) hif:xbs(4), lpc(4) ps2 (3) iic (3) other (1) numbers in parentheses are the numbers of interrupt sources. * when the watchdog timer is used as an interval timer, it generates an interrupt request at each counter overflow. note: figure 4.4 interrupt sources and number of interrupts
94 4.4 trap instruction trap instruction exception handling starts when a trapa instruction is executed. trap instruction exception handling can be executed at all times in the program execution state. the trapa instruction fetches a start address from a vector table entry corresponding to a vector number from 0 to 3, as specified in the instruction code. table 4.3 shows the status of ccr and exr after execution of trap instruction exception handling. table 4.3 status of ccr and exr after trap instruction exception handling ccr exr interrupt control mode i ui i2 to i0 t 01 111 legend: 1: set to 1 0: cleared to 0 ? retains value prior to execution.
95 4.5 stack status after exception handling figure 4.5 shows the stack after completion of trap instruction exception handling and interrupt exception handling. sp ccr ccr * pc (16 bits) interrupt control modes 0 and 1 note: * ignored on return. figure 4.5 (1) stack status after exception handling (normal mode) sp ccr pc (24bits) interrupt control modes 0 and 1 note: * ignored on return. figure 4.5 (2) stack status after exception handling (advanced mode)
96 4.6 notes on use of the stack when accessing word data or longword data, the chip assumes that the lowest address bit is 0. the stack should always be accessed by word transfer instruction or longword transfer instruction, and the value of the stack pointer (sp: er7) should always be kept even. use the following instructions to save registers: push.w rn (or mov.w rn, @-sp) push.l ern (or mov.l ern, @-sp) use the following instructions to restore registers: pop.w rn (or mov.w @sp+, rn) pop.l ern (or mov.l @sp+, ern) setting sp to an odd value may lead to a malfunction. figure 4.6 shows an example of what happens when the sp value is odd. sp legend: ccr: condition-code register pc: program counter r1l: general register r1l sp: stack pointer note: this diagram illustrates an example in which the interrupt control mode is 0, in advanced mode. sp sp ccr pc r1l pc h'fffefa h'fffefb h'fffefc h'fffefd h'fffeff mov.b r1l, @?r7 sp set to h'fffeff trap instruction executed data saved above sp contents of ccr lost figure 4.6 operation when sp value is odd
97 section 5 interrupt controller 5.1 overview 5.1.1 features the mcu control interrupts by means of an interrupt controller. the interrupt controller has the following features: ? two interrupt control modes ? either of two interrupt control modes can be set by means of the intm1 and intm0 bits in the system control register (syscr). ? priorities settable with icr ? an interrupt control register (icr) is provided for setting interrupt priorities. three priority levels can be set for each module for all interrupts except nmi and address break. ? independent vector addresses ? all interrupt sources are assigned independent vector addresses, making it unnecessary for the source to be identified in the interrupt handling routine. ? thirty-one external interrupt pins (nine external sources) ? nmi is the highest-priority interrupt, and is accepted at all times. a rising or falling edge at the nmi pin can be selected for the nmi interrupt. ? falling edge, rising edge, or both edge detection, or level sensing, at pins irq7 to irq0 can be selected for interrupts irq7 to irq0. ? the irq6 interrupt is shared by the interrupt from the irq6 pin and eight external interrupt inputs ( kin7 to kin0 ), and the irq7 interrupt is shared by the interrupt from the irq7 pin and sixteen external interrupt inputs ( kin15 to kin8 and wue7 to wue0 ). kin15 to kin0 and wue7 to wue0 can be masked individually by the user program. dtc control ? dtc activation is controlled by means of interrupts.
98 5.1.2 block diagram a block diagram of the interrupt controller is shown in figure 5.1. syscr nmi input irq input internal interrupt requests swdtend to ibfi3 intm1 intm0 nmieg nmi input unit irq input unit isr iscr ier icr interrupt controller priority determination interrupt request vector number i, ui ccr cpu irq sense control register irq enable register irq status register interrupt control register system control register legend: iscr: ier: isr: icr: syscr: figure 5.1 block diagram of interrupt controller
99 5.1.3 pin configuration table 5.1 summarizes the pins of the interrupt controller. table 5.1 interrupt controller pins name symbol i/o function nonmaskable interrupt nmi input nonmaskable external interrupt; rising or falling edge can be selected external interrupt requests 7 to 0 irq7 to irq0 input maskable external interrupts; rising, falling, or both edges, or level sensing, can be selected. key input interrupt requests 15 to 0 kin15 to kin0 input maskable external interrupts: falling edge or level sensing can be selected. wakeup event interrupt requests 7 to 0 wue7 to wue0 input maskable external interrupts: falling edge or level sensing can be selected.
100 5.1.4 register configuration table 5.2 summarizes the registers of the interrupt controller. table 5.2 interrupt controller registers name abbreviation r/w initial value address * 1 system control register syscr r/w h'09 h'ffc4 irq sense control register h iscrh r/w h'00 h'feec irq sense control register l iscrl r/w h'00 h'feed irq enable register ier r/w h'00 h'ffc2 irq status register isr r/(w) * 2 h'00 h'feeb keyboard matrix interrupt mask register kmimr r/w h'bf h'fff1 * 3 keyboard matrix interrupt mask register a kmimra r/w h'ff h'fff3 * 3 wakeup event interrupt mask register b wuemrb r/w h'ff h'fe44 interrupt control register a icra r/w h'00 h'fee8 interrupt control register b icrb r/w h'00 h'fee9 interrupt control register c icrc r/w h'00 h'feea address break control register abrkcr r/w h'00 h'fef4 break address register a bara r/w h'00 h'fef5 break address register b barb r/w h'00 h'fef6 break address register c barc r/w h'00 h'fef7 notes: 1. lower 16 bits of the address. 2. only 0 can be written, for flag clearing. 3. when setting kmimr and kmimra, the hie bit in syscr must be set to 1 and the mstp2 bit in mstpcrl must be cleared to 0.
101 5.2 register descriptions 5.2.1 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write syscr is an 8-bit readable/writable register that selects the interrupt control mode, and the detected edge for nmi, among other functions. only bits 5, 4, and 2 are described here; for details on the other bits, see section 3.2.2, system control register (syscr). syscr is initialized to h'09 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 5 and 4?nterrupt control mode 1 and 0 (intm1, intm0): these bits select one of four interrupt control modes for the interrupt controller. the intm1 bit must not be set to 1. bit 5 bit 4 interrupt intm1 intm0 control mode description 0 0 0 interrupts are controlled by i bit (initial value) 1 1 interrupts are controlled by i and ui bits and icr 1 0 2 cannot be used in the chip 1 3 cannot be used in the chip bit 2?mi edge select (nmieg): selects the input edge for the nmi pin. bit 2 nmieg description 0 interrupt request generated at falling edge of nmi input (initial value) 1 interrupt request generated at rising edge of nmi input
102 5.2.2 interrupt control registers a to c (icra to icrc) 7 icr7 0 r/w 6 icr6 0 r/w 5 icr5 0 r/w 4 icr4 0 r/w 3 icr3 0 r/w 0 icr0 0 r/w 2 icr2 0 r/w 1 icr1 0 r/w bit initial value read/write the icr registers are three 8-bit readable/writable registers that set the interrupt control level for interrupts other than nmi and address break. the correspondence between icr settings and interrupt sources is shown in table 5.3. the icr registers are initialized to h'00 by a reset and in hardware standby mode. bit n?nterrupt control level (icrn): sets the control level for the corresponding interrupt source. bit n icrn description 0 corresponding interrupt source is control level 0 (non-priority) (initial value) 1 corresponding interrupt source is control level 1 (priority) (n = 7 to 0) table 5.3 correspondence between interrupt sources and icr settings bits register 76543210 icra irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq7 dtc watchdog timer 0 watchdog timer 1 icrb a/d converter free- running timer 8-bit timer channel 0 8-bit timer channel 1 8-bit timer channels x, y hif:xbs keyboard buffer controller icrc sci channel 0 sci channel 1 sci channel 2 iic channel 0 iic channel 1 hif:lpc
103 5.2.3 irq enable register (ier) 7 irq7e 0 r/w 6 irq6e 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 irq3e 0 r/w 0 irq0e 0 r/w 2 irq2e 0 r/w 1 irq1e 0 r/w bit initial value read/write ier is an 8-bit readable/writable register that controls enabling and disabling of interrupt requests irq7 to irq0. ier is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 0?rq7 to irq0 enable (irq7e to irq0e): these bits select whether irq7 to irq0 are enabled or disabled. bit n irqne description 0 irqn interrupt disabled (initial value) 1 irqn interrupt enabled (n = 7 to 0) 5.2.4 irq sense control registers h and l (iscrh, iscrl) ? iscrh 15 irq7scb 0 r/w 14 irq7sca 0 r/w 13 irq6scb 0 r/w 12 irq6sca 0 r/w 11 irq5scb 0 r/w 8 irq4sca 0 r/w 10 irq5sca 0 r/w 9 irq4scb 0 r/w bit initial value read/write ? iscrl 7 irq3scb 0 r/w 6 irq3sca 0 r/w 5 irq2scb 0 r/w 4 irq2sca 0 r/w 3 irq1scb 0 r/w 0 irq0sca 0 r/w 2 irq1sca 0 r/w 1 irq0scb 0 r/w bit initial value read/write
104 iscrh and iscrl are 8-bit readable/writable registers that select rising edge, falling edge, or both edge detection, or level sensing, for the input at pins irq7 to irq0 . each of the iscr registers is initialized to h'00 by a reset and in hardware standby mode. iscrh bits 7 to 0, iscrl bits 7 to 0: irq7 sense control a and b (irq7sca, irq7scb) to irq0 sense control a and b (irq0sca, irq0scb) iscrh bits 7 to 0 iscrl bits 7 to 0 irq7scb to irq0scb irq7sca to irq0sca description 0 0 interrupt request generated at irq7 to irq0 input low level (initial value) 1 interrupt request generated at falling edge of irq7 to irq0 input 1 0 interrupt request generated at rising edge of irq7 to irq0 input 1 interrupt request generated at both falling and rising edges of irq7 to irq0 input 5.2.5 irq status register (isr) 7 irq7f 0 r/(w) * 6 irq6f 0 r/(w) * 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 irq3f 0 r/(w) * 0 irq0f 0 r/(w) * 2 irq2f 0 r/(w) * 1 irq1f 0 r/(w) * bit initial value read/write note: * only 0 can be written, to clear the flag. isr is an 8-bit readable/writable register that indicates the status of irq7 to irq0 interrupt requests. isr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 0?rq7 to irq0 flags (irq7f to irq0f): these bits indicate the status of irq7 to irq0 interrupt requests.
105 bit n irqnf description 0 [clearing conditions] (initial value) ? cleared by reading irqnf when set to 1, then writing 0 in irqnf ? when interrupt exception handling is executed while low-level detection is set (irqnscb = irqnsca = 0) and irqn input is high * ? when irqn interrupt exception handling is executed while falling, rising, or both-edge detection is set (irqnscb = 1 or irqnsca = 1) * 1 [setting conditions] ? when irqn input goes low when low-level detection is set (irqnscb = irqnsca = 0) ? when a falling edge occurs in irqn input while falling edge detection is set (irqnscb = 0, irqnsca = 1) ? when a rising edge occurs in irqn input while rising edge detection is set (irqnscb = 1, irqnsca = 0) ? when a falling or rising edge occurs in irqn input while both-edge detection is set (irqnscb = irqnsca = 1) (n = 7 to 0) note: * when a product, in which a dtc is incorporated, is used in the following settings, the corresponding flag bit is not automatically cleared even when exception handing, which is a clear condition, is executed and the bit is held at 1. (1) when dtcea3 is set to 1(adi is set to an interrupt source), of irq4f flag is not automatically cleared. (2) when dtcea2 is set to 1(icia is set to an interrupt source), clearing of irq5f flag is not automatically cleared. (3) when dtcea1 is set to 1(icib is set to an interrupt source), clearing of irq6f flag is not automatically cleared. (4) when dtcea0 is set to 1(ocia is set to an interrupt source), clearing of irq7f flag is not automatically cleared. when activation interrupt sources of dtc and irq interrupts are used with the above combinations, clear the interrupt flag by software in the interrupt handling routine of the corresponding irq. 5.2.6 keyboard matrix interrupt mask register (kmimr) 7 kmimr7 1 r/w 6 kmimr6 0 r/w 5 kmimr5 1 r/w 4 kmimr4 1 r/w 3 kmimr3 1 r/w 0 kmimr0 1 r/w 2 kmimr2 1 r/w 1 kmimr1 1 r/w bit initial value read/write kmimr is an 8-bit readable/writable register that performs mask control for the keyboard matrix interrupt inputs (pins kin7 to kin0 ) and pin irq6 . to enable key-sense input interrupts from multiple pin inputs in keyboard matrix scanning/sensing, clear the corresponding mask bits to 0.
106 kmimr is initialized to h'bf by a reset or in hardware standby mode and only irq6 ( kin6 ) input is enabled. bits 7 to 0?keyboard matrix interrupt mask (kmimr7 to kmimr0): these bits control key-sense input interrupt requests (kin7 to kin0). bits 7 to 0 kmimr7 to kmimr0 description 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled (initial value) * note: * however, the initial value of kmimr6 is 0, as kmimr6 bit masks the irq6 interrupt request and enables key-sense input. 5.2.7 keyboard matrix interrupt mask register a (kmimra) wakeup event interrupt mask registr b (wuemrb) bit 76543210 kmimr15 kmimr14 kmimr13 kmimr12 kmimr11 kmimr10 kmimr9 kmimr8 initial value 1 1 1 1 1 1 1 1 read/write r/w r/w r/w r/w r/w r/w r/w r/w bit 76543210 wuemr7 wuemr6 wuemr5 wuemr4 wuemr3 wuemr2 wuemr1 wuemr0 initial value 1 1 1 1 1 1 1 1 read/write r/w r/w r/w r/w r/w r/w r/w r/w kmimra is an 8-bit readable/writable register that performs mask control for the keyboard matrix interrupt inputs (pins kin15 to kin8 ). to enable key-sense input interrupts from multiple pin inputs in keyboard matrix scanning/sensing, clear the corresponding mask bits to 0. kmimra is initialized to h'ff by a reset and in hardware standby mode. bits 7 to 0?keyboard matrix interrupt mask (kmimr15 to kmimr8): these bits control key-sense input interrupt requests (kin15 to kin8).
107 bits 7 to 0 kmimr15 to kmimr8 description 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled (initial value) wuemrb is an 8-bit readable/writable register that performs mask control for the wakeup event interrupt inputs (pins wue7 to wue0 ). a wakeup event interrupt is enabled by clearing the corresponding mask bit to 0. wuemrb is initialized to h'ff by a reset and in hardware standby mode. bits 7 to 0?wakeup event interrupt mask (wuemr7 to wuemr0): these bits control wakeup event interrupt requests (wue7 to wue0). bits 7 to 0 wuemr7 to wuemr0 description 0 wakeup event interrupt requests enabled 1 wakeup event interrupt requests disabled (initial value) figure 5.2 shows the relationship between interrupts irq7 and irq6, interrupts kin15 to kin0, interrupts wue7 to wue0, and registers kmimr, kmimra, and wuemrb.
108 irq6 internal signal irq6e edge/level selection enable/disable circuit edge/level selection enable/disable circuit irq6sc irq6 interrupt kmimr0 (initial value 1) p60/ kin0 kmimr5 (initial value 1) p65/ kin5 kmimr6 (initial value 0) p66/ kin6 / irq6 kmimr7 (initial value 1) p67/ kin7 / irq7 irq7 internal signal irq7e irq7sc irq7 interrupt kmimr8 (initial value 1) pa0/ kin8 kmimr9 (initial value 1) pa1/ kin9 wuemr7 (initial value 1) pb7/ wue7 figure 5.2 relationship between interrupts irq7 and irq6, interrupts kin15 to kin0, interrupts wue7 to wue0, and registers kmimr, kmimra, and wuemrb if any of bits kmimr15 to kmimr8 or wuemrb7 to wuemrb0 is cleared to 0, interrupt input from the irq7 pin will be ignored. when pins kin7 to kin0 , kin15 to kin8 , or wue7 to wue0 are used as key-sense interrupt input pins or wakeup event interrupt input pins, either low- level sensing or falling-edge sensing must be designated as the interrupt sense condition for the corresponding interrupt source (irq6 or irq7).
109 5.2.8 address break control register (abrkcr) bit 76543210 cmf bie initial value 0 0 0 0 0 0 0 0 read/write r r/w abrkcr is an 8-bit readable/writable register that performs address break control. abrkcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?ondition match flag (cmf): this is the address break source flag, used to indicate that the address set by bar has been prefetched. when the cmf flag and bie flag are both set to 1, an address break is requested. bit 7 cmf description 0 [clearing condition] when address break interrupt exception handling is executed (initial value) 1 [setting condition] when address set by bara to barc is prefetched while bie = 1 bits 6 to 1?eserved: these bits cannot be modified and are always read as 0. bit 0?reak interrupt enable (bie): selects address break enabling or disabling. bit 0 bie description 0 address break disabled (initial value) 1 address break enabled
110 5.2.9 break address registers a, b, c (bara, barb, barc) 7 a23 0 r/w 6 a22 0 r/w 5 a21 0 r/w 4 a20 0 r/w 3 a19 0 r/w 0 a16 0 r/w 2 a18 0 r/w 1 a17 0 r/w bit bara initial value read/write 7 a15 0 r/w 6 a14 0 r/w 5 a13 0 r/w 4 a12 0 r/w 3 a11 0 r/w 0 a8 0 r/w 2 a10 0 r/w 1 a9 0 r/w bit barb initial value read/write 7 a7 0 r/w 6 a6 0 r/w 5 a5 0 r/w 4 a4 0 r/w 3 a3 0 r/w 0 0 2 a2 0 r/w 1 a1 0 r/w bit barc initial value read/write bar consists of three 8-bit readable/writable registers (bara, barb, and barc), and is used to specify the address at which an address break is to be executed. each of the bar registers is initialized to h'00 by a reset and in hardware standby mode. they are not initialized in software standby mode. bara bits 7 to 0?ddress 23 to 16 (a23 to a16) barb bits 7 to 0?ddress 15 to 8 (a15 to a8) barc bits 7 to 1?ddress 7 to 1 (a7 to a1) these bits specify the address at which an address break is to be executed. bar bits a23 to a1 are compared with internal address bus lines a23 to a1, respectively. the address at which the first instruction byte is located should be specified as the break address. occurrence of the address break condition may not be recognized for other addresses. in normal mode, no comparison is made with address lines a23 to a16. barc bit 0?eserved: this bit cannot be modified and is always read as 0.
111 5.3 interrupt sources interrupt sources comprise external interrupts (nmi and irq7 to irq0) and internal interrupts. 5.3.1 external interrupts there are nine external interrupt sources from 33 input pins (31 actual pins): nmi, irq7 to irq0 , kin15 to kin0 , and wue7 to wue0 . wue7 to wue0 and kin15 to kin8 share the irq7 interrupt source, and kin7 to kin0 share the irq6 interrupt source. of these, nmi, irq7, irq6 , and irq2 to irq0 can be used to restore the h8s/2149 chip from software standby mode. nmi interrupt: nmi is the highest-priority interrupt, and is always accepted by the cpu regardless of the interrupt control mode and the status of the cpu interrupt mask bits. the nmieg bit in syscr can be used to select whether an interrupt is requested at a rising edge or a falling edge on the nmi pin. the vector number for nmi interrupt exception handling is 7. irq7 to irq0 interrupts: interrupts irq7 to irq0 are requested by an input signal at pins irq7 to irq0 . interrupts irq7 to irq0 have the following features: using iscr, it is possible to select whether an interrupt is generated by a low level, falling edge, rising edge, or both edges, at pins irq7 to irq0 . enabling or disabling of interrupt requests irq7 to irq0 can be selected with ier. the interrupt control level can be set with icr. the status of interrupt requests irq7 to irq0 is indicated in isr. isr flags can be cleared to 0 by software. a block diagram of interrupts irq7 to irq0 is shown in figure 5.3. irqn interrupt request irqne irqnf s r q clear signal edge/level detection circuit irqnsca, irqnscb irqn input note: n: 7 to 0 figure 5.3 block diagram of interrupts irq7 to irq0
112 figure 5.4 shows the timing of irqnf setting. irqn input pin irqnf figure 5.4 timing of irqnf setting the vector numbers for irq7 to irq0 interrupt exception handling are 23 to 16. detection of irq7 to irq0 interrupts does not depend on whether the relevant pin has been set for input or output. therefore, when a pin is used as an external interrupt input pin, clear the corresponding ddr bit to 0 and do not use the pin as an i/o pin for another function. when irq6 pin is assigned as irq6 interrupt input pin, then clear the kmimr6 bit to 0. when the irq7 pin is used as the irq7 interrupt input pin, bits kmimr15 to kmimr8 and wuemrb7 to wuemrb0 must all be set to 1. if any of these bits is cleared to 0, an irq7 interrupt input from the irq7 pin will be ignored. as interrupt request flags irq7f to irq0f are set when the setting condition is met, regardless of the ier setting, only the necessary flags should be referenced. interrupts kin15 to kin0 and wue7 to wue0: interrupts kin15 to kin0 and wue7 to wue0 are requested by input signals at pins kin15 to kin0 and wue7 to wue0 . when any of pins kin15 to kin0 or wue7 to wue0 are used as key-sense inputs or wakeup events, the corresponding kmimr or wuemr bits should be cleared to 0 to enable those key-sense input interrupts or wakeup event interrupts. the remaining unused key-sense input kmimr bits and wuemr bits should be set to 1 to disable those interrupts. interrupts wue7 to wue0 and kin15 to kin8 correspond to the irq7 interrupt, and interrupts kin7 to kin0 correspond to the irq6 interrupt. interrupt request generation pin conditions, interrupt request enabling, interrupt control level setting, and interrupt request status indications, are all in accordance with the irq7 and irq6 interrupt settings. when pins kin7 to kin0 , kin15 to kin8 , or wue7 to wue0 are used as key-sense interrupt or wakeup event interrupt input pins, either low-level sensing or falling-edge sensing must be designated as the interrupt sense condition for the corresponding interrupt source (irq6 or irq7).
113 5.3.2 internal interrupts there are 48 sources for internal interrupts from on-chip supporting modules, plus one software interrupt source (address break). ? for each on-chip supporting module there are flags that indicate the interrupt request status, and enable bits that select enabling or disabling of these interrupts. if any one of these is set to 1, an interrupt request is issued to the interrupt controller. ? the interrupt control level can be set by means of icr. ? the dtc can be activated by an frt, tmr, sci, or other interrupt request. when the dtc is activated by an interrupt, the interrupt control mode and interrupt mask bits have no effect. 5.3.3 interrupt exception vector table table 5.4 shows interrupt exception handling sources, vector addresses, and interrupt priorities. for default priorities, the lower the vector number, the higher the priority. priorities among modules can be set by means of icr. the situation when two or more modules are set to the same priority, and priorities within a module, are fixed as shown in table 5.4. table 5.4 interrupt sources, vector addresses, and interrupt priorities origin of vector address interrupt source interrupt source vector number normal mode advanced mode icr priority nmi external 7 h'000e h'00001c high irq0 pin 16 h'0020 h'000040 icra7 irq1 17 h'0022 h'000044 icra6 irq2 irq3 18 19 h'0024 h'0026 h'000048 h'00004c icra5 irq4 irq5 20 21 h'0028 h'002a h'000050 h'000054 icra4 irq6, kin7 to kin0 irq7, kin15 to kin8, wue7 to wue0 22 23 h'002c h'002e h'000058 h'00005c icra3 swdtend (software activation interrupt end) dtc 24 h'0030 h'000060 icra2 wovi0 (interval timer) watchdog timer 0 25 h'0032 h'000064 icra1 wovi1 (interval timer) watchdog timer 1 26 h'0034 h'000068 icra0 low
114 origin of vector address interrupt source interrupt source vector number normal mode advanced mode icr priority address break (pc break) 27 h'0036 h'00006c high adi (a/d conversion end) a/d 28 h'0038 h'000070 icrb7 reserved 29 to 47 h'003a to h'005e h'000074 to h'0000bc icia (input capture a) icib (input capture b) icic (input capture c) icid (input capture d) ocia (output compare a) ocib (output compare b) fovi (overflow) reserved free-running timer 48 49 50 51 52 53 54 55 h'0060 h'0062 h'0064 h'0066 h'0068 h'006a h'006c h'006e h'0000c0 h'0000c4 h'0000c8 h'0000cc h'0000d0 h'0000d4 h'0000d8 h'0000dc icrb6 reserved 56 to 63 h'0070 to h'007e h'0000e0 to h'0000fc cmia0 (compare-match a) cmib0 (compare-match b) ovi0 (overflow) reserved 8-bit timer channel 0 64 65 66 67 h'0080 h'0082 h'0084 h'0086 h'000100 h'000104 h'000108 h'00010c icrb3 cmia1 (compare-match a) cmib1 (compare-match b) ovi1 (overflow) reserved 8-bit timer channel 1 68 69 70 71 h'0088 h'008a h'008c h'008e h'000110 h'000114 h'000118 h'00011c icrb2 cmiay (compare-match a) cmiby (compare-match b) oviy (overflow) icix (input capture x) 8-bit timer channels y, x 72 73 74 75 h'0090 h'0092 h'0094 h'0096 h'000120 h'000124 h'000128 h'00012c icrb1 ibf1 (idr1 reception completed) ibf2 (idr2 reception completed) ibf3 (idr3 reception completed) ibf4 (idr4 reception completed) host interface (xbs) 76 77 78 79 h'0098 h'009a h'009c h'009e h'000130 h'000134 h'000138 h'00013c icrb0 eri0 (receive error 0) rxi0 (reception completed 0) txi0 (transmit data empty 0) tei0 (transmission end 0) sci channel 0 80 81 82 83 h'00a0 h'00a2 h'00a4 h'00a6 h'000140 h'000144 h'000148 h'00014c icrc7 low
115 origin of vector address interrupt source interrupt source vector number normal mode advanced mode icr priority eri1 (receive error 1) rxi1 (reception completed 1) txi1 (transmit data empty 1) tei1 (transmission end 1) sci channel 1 84 85 86 87 h'00a8 h'00aa h'00ac h'00ae h'000150 h'000154 h'000158 h'00015c icrc6 high eri2 (receive error 2) rxi2 (reception completed 2) txi2 (transmit data empty 2) tei2 (transmission end 2) sci channel 2 88 89 90 91 h'00b0 h'00b2 h'00b4 h'00b6 h'000160 h'000164 h'000168 h'00016c icrc5 iici0 (1-byte transmission/ reception completed) ddcswi (format switch) iic channel 0 92 93 h'00b8 h'00ba h'000170 h'000174 icrc4 iici1 (1-byte transmission/ reception completed) reserved iic channel 1 94 95 h'00bc h'00be h'000178 h'00017c icrc3 ps2ia (reception completed a) ps2ib (reception completed b) ps2ic (reception completed c) reserved keyboard buffer controller (ps2) 96 97 98 99 h'00c0 h'00c2 h'00c4 h'00c6 h'000180 h'000184 h'000188 h'00018c icrb0 reserved 100 to 103 h'00c8 to h'00ce h'000190 to h'00019c erri (transfer error, etc.) ibfi1 (idr1 reception completed) ibfi2 (idr2 reception completed) ibfi3 (idr3 reception completed) host interface (lpc) 104 105 106 107 h'00d8 h'00da h'00dc h'00de h'0001b0 h'0001b4 h'0001b8 h'0001bc icrc1 low
116 5.4 address breaks 5.4.1 features with the h8s/2169 or h8s/2149, it is possible to identify the prefetch of a specific address by the cpu and generate an address break interrupt, using the abrkcr and bar registers. when an address break interrupt is generated, address break interrupt exception handling is executed. this function can be used to detect the beginning of execution of a bug location in the program, and branch to a correction routine. 5.4.2 block diagram a block diagram of the address break function is shown in figure 5.5. bar abrkcr comparator match signal control logic address break interrupt request internal address prefetch signal (internal signal) figure 5.5 block diagram of address break function
117 5.4.3 operation abrkcr and bar settings can be made so that an address break interrupt is generated when the cpu prefetches the address set in bar. this address break function issues an interrupt request to the interrupt controller when the address is prefetched, and the interrupt controller determines the interrupt priority. when the interrupt is accepted, interrupt exception handling is started on completion of the currently executing instruction. with an address break interrupt, interrupt mask control by the i and ui bits in the cpu? ccr is ineffective. the register settings when the address break function is used are as follows. 1. set the break address in bits a23 to a1 in bar. 2. set the bie bit in abrkcr to 1 to enable address breaks. an address break will not be requested if the bie bit is cleared to 0. when the setting condition occurs, the cmf flag in abrkcr is set to 1 and an interrupt is requested. if necessary, the source should be identified in the interrupt handling routine. 5.4.4 usage notes ? with the address break function, the address at which the first instruction byte is located should be specified as the break address. occurrence of the address break condition may not be recognized for other addresses. ? in normal mode, no comparison is made with address lines a23 to a16. ? if a branch instruction (bcc, bsr), jump instruction (jmp, jsr), rts instruction, or rte instruction is located immediately before the address set in bar, execution of this instruction will output a prefetch signal for that address, and an address break may be requested. this can be prevented by not making a break address setting for an address immediately following one of these instructions, or by determining within the interrupt handling routine whether interrupt handling was initiated by a genuine condition occurrence. ? as an address break interrupt is generated by a combination of the internal prefetch signal and address, the timing of the start of interrupt exception handling depends on the content and execution cycle of the instruction at the set address and the preceding instruction. figure 5.6 shows some address timing examples.
118 address bus break request signal breakpoint nop instruction is executed at breakpoint address h'0312 and next address, h'0314; fetch from address h'0316 starts after end of exception handling. instruction fetch internal operation internal operation vector fetch stack save instruction fetch h'0310 nop execution h'0310 nop h'0312 nop h'0314 nop h'0316 nop nop execution nop execution interrupt exception handling h'0312 h'0314 h'0316 h'0318 h'0036 sp-2 sp-4 ? program area in on-chip memory, 1-state execution instruction at specified break address instruction fetch address bus break request signal breakpoint mov instruction is executed at breakpoint address h'0312, nop instruction at next address, h'0316, is not executed; fetch from address h'0316 starts after end of exception handling. internal operation internal operation vector fetch stack save instruction fetch h'0310 nop execution h'0310 nop h'0312 mov.w #xx:16,rd h'0316 nop h'0318 nop mov.w execution interrupt exception handling h'0312 h'0314 h'0316 h'0318 h'0036 sp-2 sp-4 ? program area in on-chip memory, 2-state execution instruction at specified break address address bus break request signal breakpoint nop instruction at breakpoint address h'0312 is not executed; fetch from address h'0312 starts after end of exception handling. instruction fetch internal operation internal operation vector fetch stack save h'0310 nop execution h'0310 nop h'0312 nop h'0314 nop h'0316 nop interrupt exception handling h'0312 h'0314 h'0036 sp-2 sp-4 ? program area in external memory (2-state access, 16-bit-bus access), 1-state execution instruction at specified break address instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch instruction fetch figure 5.6 examples of address break timing
119 5.5 interrupt operation 5.5.1 interrupt control modes and interrupt operation interrupt operations in the h8s/2169 or h8s/2149 differ depending on the interrupt control mode. nmi and address break interrupts are accepted at all times except in the reset state and the hardware standby state. in the case of irq interrupts and on-chip supporting module interrupts, an enable bit is provided for each interrupt. clearing an enable bit to 0 disables the corresponding interrupt request. interrupt sources for which the enable bits are set to 1 are controlled by the interrupt controller. table 5.5 shows the interrupt control modes. the interrupt controller performs interrupt control according to the interrupt control mode set by the intm1 and intm0 bits in syscr, the priorities set in icr, and the masking state indicated by the i and ui bits in the cpu? ccr. table 5.5 interrupt control modes interrupt syscr priority setting interrupt control mode intm1 intm0 register mask bits description 0 0 0 icr i interrupt mask control is performed by the i bit priority can be set with icr 1 1 icr i, ui 3-level interrupt mask control is performed by the i and ui bits priority can be set with icr
120 figure 5.7 shows a block diagram of the priority decision circuit. icr ui i default priority determination vector number interrupt acceptance control and 3-level mask control interrupt source interrupt control modes 0 and 1 figure 5.7 block diagram of interrupt control operation interrupt acceptance control and 3-level control: in interrupt control modes 0 and 1, interrupt acceptance control and 3-level mask control is performed by means of the i and ui bits in ccr, and icr (control level). table 5.6 shows the interrupts selected in each interrupt control mode. table 5.6 interrupts selected in each interrupt control mode interrupt mask bits interrupt control mode i ui selected interrupts 00 * all interrupts (control level 1 has priority) 1 * nmi and address break interrupt 10 * all interrupts (control level 1 has priority) 1 0 nmi, address break and control level 1 interrupts 1 nmi and address break interrupt legend: * : don? care
121 default priority determination: the priority is determined for the selected interrupt, and a vector number is generated. if the same value is set for icr, acceptance of multiple interrupts is enabled, and so only the interrupt source with the highest priority according to the preset default priorities is selected and has a vector number generated. interrupt sources with a lower priority than the accepted interrupt source are held pending. table 5.7 shows operations and control signal functions in each interrupt control mode. table 5.7 operations and control signal functions in each interrupt control mode interrupt setting interrupt acceptance control 3-level control default priority control mode intm1 intm0 i ui icr determination t (trace) 000 o im pr o 11 o im im pr o legend: o: interrupt operation control performed im: used as interrupt mask bit pr: sets priority ? not used
122 5.5.2 interrupt control mode 0 enabling and disabling of irq interrupts and on-chip supporting module interrupts can be set by means of the i bit in the cpu? ccr, and icr. interrupts are enabled when the i bit is cleared to 0, and disabled when set to 1. control level 1 interrupt sources have higher priority. figure 5.8 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. when interrupt requests are sent to the interrupt controller, a control level 1 interrupt, according to the control level set in icr, has priority for selection, and other interrupt requests are held pending. if a number of interrupt requests with the same control level setting are generated at the same time, the interrupt request with the highest priority according to the priority system shown in table 5.4 is selected. 3. the i bit is then referenced. if the i bit is cleared to 0, the interrupt request is accepted. if the i bit is set to 1, only an nmi and address break interrupt is accepted, and other interrupt requests are held pending. 4. when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. 5. the pc and ccr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. next, the i bit in ccr is set to 1. this disables all interrupts except nmi and address break interrupt. 7. a vector address is generated for the accepted interrupt, and execution of the interrupt handling routine starts at the address indicated by the contents of that vector address.
123 program execution state interrupt generated? nmi? control level 1 interrupt? irq0? irq1? ibfi3? irq0? irq1? ibfi3? i = 0? save pc and ccr i 1 read vector address branch to interrupt handling routine yes no yes yes yes no no yes no yes no yes yes no no yes yes no hold pending figure 5.8 flowchart of procedure up to interrupt acceptance in interrupt?ontrol?ode?
124 5.5.3 interrupt control mode 1 three-level masking is implemented for irq interrupts and on-chip supporting module interrupts by means of the i and ui bits in the cpu? ccr, and icr. ? control level 0 interrupt requests are enabled when the i bit is cleared to 0, and disabled when set to 1. ? control level 1 interrupt requests are enabled when the i bit or ui bit is cleared to 0, and disabled when both the i bit and the ui bit are set to 1. for example, if the interrupt enable bit for an interrupt request is set to 1, and h'20, h'00, and h'00 are set in icra, icrb, and icrc, respectively, (i.e. irq2 and irq3 interrupts are set to control level 1 and other interrupts to control level 0), the situation is as follows: ? when i = 0, all interrupts are enabled (priority order: nmi > irq2 > irq3 > address break > irq0 > irq1 ...) ? when i = 1 and ui = 0, only nmi, irq2, irq3 and address break interrupts are enabled ? when i = 1 and ui = 1, only nmi and address break interrupts are enabled figure 5.9 shows the state transitions in these cases. only nmi and address break interrupts enabled all interrupts enabled exception handling execution or i 1, ui 1 i 0 i 1, ui 0 i 0ui 0 exception handling execution or ui 1 only nmi, address break, irq2, and irq3 interrupts enabled figure 5.9 example of state transitions in interrupt control mode 1
125 figure 5.10 shows a flowchart of the interrupt acceptance operation in this case. 1. if an interrupt source occurs when the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. 2. when interrupt requests are sent to the interrupt controller, a control level 1 interrupt, according to the control level set in icr, has priority for selection, and other interrupt requests are held pending. if a number of interrupt requests with the same control level setting are generated at the same time, the interrupt request with the highest priority according to the priority system shown in table 5.4 is selected. 3. the i bit is then referenced. if the i bit is cleared to 0, the ui bit has no effect. an interrupt request set to interrupt control level 0 is accepted when the i bit is cleared to 0. if the i bit is set to 1, only an nmi and address break interrupt are accepted, and other interrupt requests are held pending. an interrupt request set to interrupt control level 1 has priority over an interrupt request set to interrupt control level 0, and is accepted if the i bit is cleared to 0, or if the i bit is set to 1 and the ui bit is cleared to 0. when both the i bit and the ui bit are set to 1, only an nmi and address break interrupt are accepted, and other interrupt requests are held pending. 4. when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. 5. the pc and ccr are saved to the stack area by interrupt exception handling. the pc saved on the stack shows the address of the first instruction to be executed after returning from the interrupt handling routine. 6. next, the i and ui bits in ccr are set to 1. this disables all interrupts except nmi and address break. 7. a vector address is generated for the accepted interrupt, and execution of the interrupt handling routine starts at the address indicated by the contents of that vector address.
126 program execution state interrupt generated? nmi? control level 1 interrupt? irq0? irq1? ibfi3? irq0? irq1? ibfi3? ui = 0? save pc and ccr i 1, ui 1 read vector address branch to interrupt handling routine yes no yes yes yes no no yes no yes no yes yes no no yes yes no hold pending i = 0? i = 0 yes yes no no figure 5.10 flowchart of procedure up to interrupt acceptance in interrupt?ontrol?ode?
127 5.5.4 interrupt exception handling sequence figure 5.11 shows the interrupt exception handling sequence. the example shown is for the case where interrupt control mode 0 is set in advanced mode, and the program area and stack area are in on-chip memory.
128 (14) (12) (10) (8) (6) (4) (2) (1) (5) (7) (9) (11) (13) interrupt handling routine instruction prefetch internal operation vector fetch stack instruction prefetch internal operation interrupt acceptance interrupt level determination wait for end of instruction interrupt request signal internal address bus internal read signal internal write signal internal data bus (3) (1) (2) (4) (3) (5) (7) instruction prefetch address (not executed. this is the contents of the saved pc, the return address.) instruction code (not executed.) instruction prefetch address (not executed.) sp-2 sp-4 saved pc and saved ccr vector address interrupt handling routine start address (vector address contents) interrupt handling routine start address ((13) = (10) (12)) first instruction of interrupt handling routine (6) (8) (9) (11) (10) (12) (13) (14) figure 5.11 interrupt exception handling
129 5.5.5 interrupt response times the h8s/2149 is capable of fast word access to on-chip memory, and high-speed processing can be achieved by providing the program area in on-chip rom and the stack area in on-chip ram. table 5.8 shows interrupt response times?he interval between generation of an interrupt request and execution of the first instruction in the interrupt handling routine. the symbols used in table 5.8 are explained in table 5.9. table 5.8 interrupt response times number of states no. item normal mode advanced mode 1 interrupt priority determination * 1 33 2 number of wait states until executing instruction ends * 2 1 to (19+2? i ) 1 to (19+2? i ) 3 pc, ccr stack save 2? k 2? k 4 vector fetch s i 2? i 5 instruction fetch * 3 2? i 2? i 6 internal processing * 4 22 total (using on-chip memory) 11 to 31 12 to 32 notes: 1. two states in case of internal interrupt. 2. refers to mulxs and divxs instructions. 3. prefetch after interrupt acceptance and interrupt handling routine prefetch. 4. internal processing after interrupt acceptance and internal processing after vector fetch. table 5.9 number of states in interrupt handling routine execution object of access external device 8-bit bus 16-bit bus symbol internal memory 2-state access 3-state access 2-state access 3-state access instruction fetch s i 1 4 6+2m 2 3+m branch address read s j stack manipulation s k legend: m: number of wait states in an external device access
130 5.6 usage notes 5.6.1 contention between interrupt generation and disabling when an interrupt enable bit is cleared to 0 to disable interrupts, the disabling becomes effective after execution of the instruction. in other words, when an interrupt enable bit is cleared to 0 by an instruction such as bclr or mov, if an interrupt is generated during execution of the instruction, the interrupt concerned will still be enabled on completion of the instruction, and so interrupt exception handling for that interrupt will be executed on completion of the instruction. however, if there is an interrupt request of higher priority than that interrupt, interrupt exception handling will be executed for the higher-priority interrupt, and the lower-priority interrupt will be ignored. the same also applies when an interrupt source flag is cleared to 0. figure 5.12 shows an example in which the cmiea bit in 8-bit timer register tcr is cleared to 0. internal address bus internal write signal cmiea cmfa cmia interrupt signal tcr write cycle by cpu cmia exception handling tcr address figure 5.12 contention between interrupt generation and disabling the above contention will not occur if an enable bit or interrupt source flag is cleared to 0 while the interrupt is masked.
131 5.6.2 instructions that disable interrupts instructions that disable interrupts are ldc, andc, orc, and xorc. after any of these instructions is executed, all interrupts except nmi are disabled and the next instruction is always executed. when the i bit or ui bit is set by one of these instructions, the new value becomes valid two states after execution of the instruction ends. 5.6.3 interrupts during execution of eepmov instruction interrupt operation differs between the eepmov.b instruction and the eepmov.w instruction. with the eepmov.b instruction, an interrupt request (including nmi) issued during the transfer is not accepted until the move is completed. with the eepmov.w instruction, if an interrupt request is issued during the transfer, interrupt exception handling starts at a break in the transfer cycle. the pc value saved on the stack in this case is the address of the next instruction. therefore, if an interrupt is generated during execution of an eepmov.w instruction, the following coding should be used. l1: eepmov.w mov.w r4,r4 bne l1
132 5.7 dtc activation by interrupt 5.7.1 overview the dtc can be activated by an interrupt. in this case, the following options are available: ? interrupt request to cpu ? activation request to dtc ? both of the above for details of interrupt requests that can be used to activate the dtc, see section 7, data transfer controller. 5.7.2 block diagram figure 5.13 shows a block diagram of the dtc and interrupt controller. selection circuit dtcer dtvecr control logic determination of priority cpu dtc dtc activation request vector number clear signal cpu interrupt request vector number select signal interrupt request interrupt source clear signal irq interrupt on-chip supporting module clear signal interrupt controller i, ui swdte clear signal figure 5.13 interrupt control for dtc
133 5.7.3 operation the interrupt controller has three main functions in dtc control. selection of interrupt source: it is possible to select dtc activation request or cpu interrupt request with the dtce bit of dtcera to dtcere in the dtc. after a dtc data transfer, the dtce bit can be cleared to 0 and an interrupt request sent to the cpu in accordance with the specification of the disel bit of mrb in the dtc. when the dtc performs the specified number of data transfers and the transfer counter reaches 0, following the dtc data transfer the dtce bit is cleared to 0 and an interrupt request is sent to the cpu. determination of priority: the dtc activation source is selected in accordance with the default priority order, and is not affected by mask or priority levels. see section 7.3.3, dtc vector table, for the respective priorities. operation order: if the same interrupt is selected as a dtc activation source and a cpu interrupt source, the dtc data transfer is performed first, followed by cpu interrupt exception handling. table 5.10 summarizes interrupt source selection and interrupt source clearance control according to the settings of the dtce bit of dtcera to dtcere in the dtc and the disel bit of mrb in the dtc. table 5.10 interrupt source selection and clearing control settings dtc interrupt source selection/clearing control dtce disel dtc cpu 0 * ? 10 d 1 d legend d : the relevant interrupt is used. interrupt source clearing is performed. (the cpu should clear the source flag in the interrupt handling routine.) : the relevant interrupt is used. the interrupt source is not cleared. : the relevant bit cannot be used. * : don? care usage note: sci, iic, and a/d converter interrupt sources are cleared when the dtc reads or writes to the prescribed register, and are not dependent upon the disel bit.
134
135 section 6 bus controller 6.1 overview the h8s/2169 or h8s/2149 has a built-in bus controller (bsc) that allows external address space bus specifications, such as bus width and number of access states, to be set. the bus controller also has a bus arbitration function, and controls the operation of the internal bus masters: the cpu and data transfer controller (dtc). 6.1.1 features the features of the bus controller are listed below. basic bus interface ? 2-state access or 3-state access can be selected ? program wait states can be inserted burst rom interface ? external space can be designated as rom interface space ? 1-state or 2-state burst access can be selected idle cycle insertion ? an idle cycle can be inserted when an external write cycle immediately follows an external read cycle bus arbitration function ? includes a bus arbiter that arbitrates bus mastership between the cpu and dtc
136 6.1.2 block diagram figure 6.1 shows a block diagram of the bus controller. bus controller bcr wscr wait controller bus arbiter internal control signals bus mode signal internal data bus cpu bus request signal dtc bus request signal cpu bus acknowledge signal dtc bus acknowledge signal external bus control signals wait figure 6.1 block diagram of bus controller
137 6.1.3 pin configuration table 6.1 summarizes the pins of the bus controller. table 6.1 bus controller pins name symbol i/o function address strobe as output strobe signal indicating that address output on address bus is enabled (when iose bit is 0) i/o select ios output i/o select signal (when iose bit is 1) read rd output strobe signal indicating that external space is being read high write hwr output strobe signal indicating that external space is being written to, and that the upper data bus (d15 to d8) is enabled low write lwr output strobe signal indicating that external space is being written to, and that the lower data bus (d7 to d0) is enabled wait wait input wait request signal when external 3-state access space is accessed 6.1.4 register configuration table 6.2 summarizes the registers of the bus controller. table 6.2 bus controller registers name abbreviation r/w initial value address * bus control register bcr r/w h'd7 h'ffc6 wait state control register wscr r/w h'33 h'ffc7 note: * lower 16 bits of the address.
138 6.2 register descriptions 6.2.1 bus control register (bcr) 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 ? 1 r/w 1 ios1 1 r/w bit initial value read/write bcr is an 8-bit readable/writable register that specifies the external memory space access mode, and the extent of the i/o area when the i/o strobe function has been selected for the as pin. bcr is initialized to h'd7 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?idle cycle insert 1 (icis1): reserved. do not write 0 to this bit. bit 6?idle cycle insert 0 (icis0): selects whether or not a one-state idle cycle is to be inserted between bus cycles when successive external read and external write cycles are performed. bit 6 icis0 description 0 idle cycle not inserted in case of successive external read and external write cycles 1 idle cycle inserted in case of successive external read and external write cycles (initial value) bit 5?burst rom enable (brstrm): selects whether external space is designated as a burst rom interface space. the selection applies to the entire external space . bit 5 brstrm description 0 basic bus interface (initial value) 1 burst rom interface bit 4?burst cycle select 1 (brsts1): selects the number of burst cycles for the burst rom interface.
139 bit 4 brsts1 description 0 burst cycle comprises 1 state 1 burst cycle comprises 2 states (initial value) bit 3?burst cycle select 0 (brsts0): selects the number of words that can be accessed in a burst rom interface burst access. bit 3 brsts0 description 0 max. 4 words in burst access (initial value) 1 max. 8 words in burst access bit 2?reserved: do not write 0 to this bit. bits 1 and 0?ios select 1 and 0 (ios1, ios0): see table 6.4. 6.2.2 wait state control register (wscr) 7 rams 0 r/w 6 ram0 0 r/w 5 abw 1 r/w 4 ast 1 r/w 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w bit initial value read/write wscr is an 8-bit readable/writable register that specifies the data bus width, number of access states, wait mode, and number of wait states for external memory space. the on-chip memory and internal i/o register bus width and number of access states are fixed, irrespective of the wscr settings. wscr is initialized to h'33 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?ram select (rams)/bit 6?ram area setting (ram0): reserved bits. do not write 1 to these bits. bit 5?bus width control (abw): specifies whether the external memory space is 8-bit access space or 16-bit access space.
140 bit 5 abw description 0 external memory space is designated as 16-bit access space 1 external memory space is designated as 8-bit access space (initial value) bit 4?access state control (ast): specifies whether the external memory space is 2-state access space or 3-state access space, and simultaneously enables or disables wait state insertion. bit 4 ast description 0 external memory space is designated as 2-state access space wait state insertion in external memory space accesses is disabled 1 external memory space is designated as 3-state access space (initial value) wait state insertion in external memory space accesses is enabled bits 3 and 2?wait mode select 1 and 0 (wms1, wms0): these bits select the wait mode when external memory space is accessed while the ast bit is set to 1. bit 3 bit 2 wms1 wms0 description 0 0 program wait mode (initial value) 1 wait-disabled mode 1 0 pin wait mode 1 pin auto-wait mode bits 1 and 0?wait count 1 and 0 (wc1, wc0): these bits select the number of program wait states when external memory space is accessed while the ast bit is set to 1. bit 1 bit 0 wc1 wc0 description 0 0 no program wait states are inserted 1 1 program wait state is inserted in external memory space accesses 1 0 2 program wait states are inserted in external memory space accesses 1 3 program wait states are inserted in external memory space accesses (initial value)
141 6.3 overview of bus control 6.3.1 bus specifications the external space bus specifications consist of three elements: bus width, number of access states, and wait mode and number of program wait states. the bus width and number of access states for on-chip memory and internal i/o registers are fixed, and are not affected by the bus controller. bus width: a bus width of 8 or 16 bits can be selected with the abw bit. number of access states: two or three access states can be selected with the ast bit. when 2-state access space is designated, wait insertion is disabled. the number of access states on the burst rom interface is determined without regard to the ast bit setting. wait mode and number of program wait states: when 3-state access space is designated by the ast bit, the wait mode and the number of program wait states to be inserted automatically is selected with wms1, wms0, wc1, and wc0. from 0 to 3 program wait states can be selected. table 6.3 shows the bus specifications for each basic bus interface area. table 6.3 bus specifications for each area (basic bus interface) bus specifications (basic bus interface) abw ast wms1 wms0 wc1 wc0 bus width access states program wait states 0 0 ???? 16 2 0 101?? 16 3 0 ? * ? * 00 3 0 11 10 2 13 1 0 ???? 8 2 0 101?? 8 3 0 ? * ? * 00 3 0 11 10 2 13 note: * except when wms1 = 0 and wms0 = 1
142 6.3.2 advanced mode the initial state of the external space is basic bus interface, three-state access space. in rom- enabled expanded mode, the space excluding the on-chip rom, on-chip ram, and internal i/o registers is external space. the on-chip ram is enabled when the rame bit in the system control register (syscr) is set to 1; when the rame bit is cleared to 0, the on-chip ram is disabled and the corresponding space becomes external space. 6.3.3 normal mode the initial state of the external memory space is basic bus interface, three-state access space. in rom-disabled expanded mode, the space excluding the on-chip ram and internal i/o registers is external space. in rom-enabled expanded mode, the space excluding the on-chip rom, on-chip ram, and internal i/o registers is external space. the on-chip ram is enabled when the rame bit in the system control register (syscr) is set to 1; when the rame bit is cleared to 0, the on- chip ram is disabled and the corresponding space becomes external space. 6.3.4 i/o select signal in the h8s/2169 or h8s/2149, an i/o select signal ( ios ) can be output, with the signal output going low when the designated external space is accessed. figure 6.2 shows an example of ios signal output timing. ? address bus ios t 1 t 2 t 3 bus cycle external address in ios set range figure 6.2 ios signal output timing
143 enabling or disabling of ios signal output is controlled by the setting of the iose bit in syscr. in expanded mode, this pin operates as the as output pin after a reset, and therefore the iose bit in syscr must be set to 1 in order to use this pin as the ios signal output. see section 8, i/o ports, for details. the range of addresses for which the ios signal is output can be set with bits ios1 and ios0 in bcr. the ios signal address ranges are shown in table 6.4. table 6.4 ios signal output range settings ios1 ios0 ios signal output range 0 0 h'(ff)f000 to h'(ff)f03f 1 h'(ff)f000 to h'(ff)f0ff 1 0 h'(ff)f000 to h'(ff)f3ff 1 h'(ff)f000 to h'(ff)f7ff (initial value) 6.4 basic bus interface 6.4.1 overview the basic bus interface enables direct connection of rom, sram, and so on. the bus specifications can be selected with the abw bit, the ast bit, and the wms1, wms0, wc1, and wc0 bits (see table 6.3). 6.4.2 data size and data alignment data sizes for the cpu and other internal bus masters are byte, word, and longword. the bus controller has a data alignment function, and when accessing external space, controls whether the upper data bus (d15 to d8) or lower data bus (d7 to d0) is used according to the bus specifications for the area being accessed (8-bit access space or 16-bit access space) and the data size. 8-bit access space: figure 6.3 illustrates data alignment control for the 8-bit access space. with the 8-bit access space, the upper data bus (d15 to d8) is always used for accesses. the amount of data that can be accessed at one time is one byte: a word access is performed as two byte accesses, and a longword access, as four byte accesses.
144 d15 d8 d7 d0 upper data bus lower data bus byte size word size 1st bus cycle 2nd bus cycle longword size 1st bus cycle 2nd bus cycle 3rd bus cycle 4th bus cycle figure 6.3 access sizes and data alignment control (8-bit access space) 16-bit access space: figure 6.4 illustrates data alignment control for the 16-bit access space. with the 16-bit access space, the upper data bus (d15 to d8) and lower data bus (d7 to d0) are used for accesses. the amount of data that can be accessed at one time is one byte or one word, and a longword access is executed as two word accesses. in byte access, whether the upper or lower data bus is used is determined by whether the address is even or odd. the upper data bus is used for an even address, and the lower data bus for an odd address. d15 d8 d7 d0 upper data bus byte size word size 1st bus cycle 2nd bus cycle longword size even address byte size odd address lower data bus figure 6.4 access sizes and data alignment control (16-bit access space)
145 6.4.3 valid strobes table 6.5 shows the data buses used and valid strobes for the access spaces. in a read, the rd signal is valid without discrimination between the upper and lower halves of the data bus. in a write, the hwr signal is valid for the upper half of the data bus, and the lwr signal for the lower half. table 6.5 data buses used and valid strobes area access size read/ write address valid strobe upper data bus (d15 to d8) lower data bus (d7 to d0) 8-bit access byte read ? rd valid port, etc. space write ? hwr port, etc. 16-bit access byte read even rd valid invalid space odd invalid valid write even hwr valid undefined odd lwr undefined valid word read ? rd valid valid write ? hwr , lwr valid valid notes: undefined: undefined data is output. invalid: input state; input value is ignored. port, etc.: pins are used as port or on-chip supporting module input/output pins, and not as data bus pins.
146 6.4.4 basic timing 8-bit 2-state access space: figure 6.5 shows the bus timing for an 8-bit 2-state access space. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states cannot be inserted. bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr d15 to d8 valid write figure 6.5 bus timing for 8-bit 2-state access space
147 8-bit 3-state access space: figure 6.6 shows the bus timing for an 8-bit 3-state access space. when an 8-bit access space is accessed, the upper half (d15 to d8) of the data bus is used. wait states can be inserted. bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr d15 to d8 valid write t 3 figure 6.6 bus timing for 8-bit 3-state access space
148 16-bit, 2-state access space: figures 6.7 to 6.9 show the bus timing for 16-bit, 2-state access space. when 16-bit access space is accessed, the upper data bus (d15 to d8) is used for even addresses and the lower data bus (d7 to d0) for odd addresses. wait states cannot be inserted. bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 undefined write high figure 6.7 16-bit, 2-state access space bus timing (1) (even address byte access)
149 bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 undefined d7 to d0 valid write high figure 6.8 16-bit, 2-state access space bus timing (2) (odd address byte access)
150 bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 valid read hwr lwr d15 to d8 valid d7 to d0 valid write figure 6.9 16-bit, 2-state access space bus timing (3) (word access)
151 16-bit, 3-state access space: figures 6.10 to 6.12 show the bus timing for 16-bit, 3-state access space. when 16-bit access space is accessed, the upper data bus (d15 to d8) is used for even addresses and the lower data bus (d7 to d0) for odd addresses. wait states can be inserted. bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 invalid read hwr lwr d15 to d8 valid d7 to d0 undefined write high t 3 figure 6.10 16-bit, 3-state access space bus timing (1) (even address byte access)
152 bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 invalid d7 to d0 valid read hwr lwr d15 to d8 undefined d7 to d0 valid write high t 3 figure 6.11 16-bit, 3-state access space bus timing (2) (odd address byte access)
153 bus cycle t 1 t 2 address bus ? as / ios (iose = 1) as / ios (iose = 0) rd d15 to d8 valid d7 to d0 valid read hwr lwr d15 to d8 valid d7 to d0 valid write t 3 figure 6.12 16-bit, 3-state access space bus timing (3) (word access)
154 6.4.5 wait control when accessing external space, the mcu can extend the bus cycle by inserting one or more wait states (t w ). there are three ways of inserting wait states: program wait insertion, pin wait insertion using the wait pin, and a combination of the two. program wait mode in program wait mode, the number of t w states specified by bits wc1 and wc0 are always inserted between the t 2 and t 3 states when external space is accessed. pin wait mode in pin wait mode, the number of t w states specified by bits wc1 and wc0 are always inserted between the t 2 and t 3 states when external space is accessed. if the wait pin is low at the fall of ? in the last t 2 or t w state, another t w state is inserted. if the wait pin is held low, t w states are inserted until it goes high. pin wait mode is useful for inserting four or more wait states, or for changing the number of t w states for different external devices. pin auto-wait mode in pin auto-wait mode, if the wait pin is low at the fall of ? in the t 2 state, the number of t w states specified by bits wc1 and wc0 are inserted when external space is accessed. no additional t w states are inserted even if the wait pin remains low. pin auto-wait mode can be used for an easy interface to low-speed memory, simply by routing the chip select signal to the wait pin. figure 6.13 shows an example of wait state insertion timing.
155 by program wait t 1 address bus ? as (iose = 0) rd data bus read data read hwr , lwr write data write note: indicates the timing of wait pin sampling using the ? clock. wait data bus t 2 t w t w t w t 3 by wait pin figure 6.13 example of wait state insertion timing the settings after a reset are: 3-state access, insertion of 3 program wait states, and wait input disabled.
156 6.5 burst rom interface 6.5.1 overview with the h8s/2169 or h8s/2149, external space area 0 can be designated as burst rom space, and burst rom interfacing can be performed. external space can be designated as burst rom space by means of the brstrm bit in bcr. consecutive burst accesses of a maximum of 4 words or 8 words can be performed for cpu instruction fetches only. one or two states can be selected for burst access. 6.5.2 basic timing the number of states in the initial cycle (full access) of the burst rom interface is in accordance with the setting of the ast bit. also, when the ast bit is set to 1, wait state insertion is possible. one or two states can be selected for the burst cycle, according to the setting of the brsts1 bit in bcr. wait states cannot be inserted. when the brsts0 bit in bcr is cleared to 0, burst access of up to 4 words is performed; when the brsts0 bit is set to 1, burst access of up to 8 words is performed. the basic access timing for burst rom space is shown in figure 6.14 (a) and (b). the timing shown in figure 6.14 (a) is for the case where the ast and brsts1 bits are both set to 1, and that in figure 6.14 (b) is for the case where both these bits are cleared to 0. t 1 address bus ? as / ios (iose = 0) data bus t 2 t 3 t 1 t 2 t 1 full access t 2 rd burst access only lower address changed read data read data read data figure 6.14 (a) example of burst rom access timing (when ast = brsts1 = 1)
157 t 1 address bus ? as / ios (iose = 0) data bus t 2 t 1 t 1 full access rd burst access only lower address changed read data read data read data figure 6.14 (b) example of burst rom access timing (when ast = brsts1 = 0) 6.5.3 wait control as with the basic bus interface, either program wait insertion or pin wait insertion using the wait pin can be used in the initial cycle (full access) of the burst rom interface. see section 6.4.5, wait control. wait states cannot be inserted in a burst cycle.
158 6.6 idle cycle 6.6.1 operation when the h8s/2169 or h8s/2149 chip accesses external space, it can insert a 1-state idle cycle (t i ) between bus cycles when a write cycle occurs immediately after a read cycle. by inserting an idle cycle it is possible, for example, to avoid data collisions between rom, with a long output floating time, and high-speed memory, i/o interfaces, and so on. if an external write occurs after an external read while the icis0 bit in bcr is set to 1, an idle cycle is inserted at the start of the write cycle. this is enabled in advanced mode and normal mode. figure 6.15 shows an example of the operation in this case. in this example, bus cycle a is a read cycle from rom with a long output floating time, and bus cycle b is a cpu write cycle. in (a), an idle cycle is not inserted, and a collision occurs in cycle b between the read data from rom and the cpu write data. in (b), an idle cycle is inserted, and a data collision is prevented. t 1 address bus ? rd bus cycle a data bus t 2 t 3 t 1 t 2 bus cycle b long output floating time data collision (a) idle cycle not inserted t 1 ? rd t 2 t 3 t i t 1 (b) idle cycle inserted t 2 hwr , lwr hwr , lwr address bus data bus bus cycle a bus cycle b figure 6.15 example of idle cycle operation
159 6.6.2 pin states in idle cycle table 6.5 shows pin states in an idle cycle. table 6.5 pin states in idle cycle pins pin state a23 to a0, ios contents of next bus cycle d15 to d0 high impedance as high rd high hwr , lwr high 6.7 bus arbitration 6.7.1 overview the h8s/2169 or h8s/2149 has a bus arbiter that arbitrates bus master operations. there are two bus masters, the cpu and the dtc, which perform read/write operations when they have possession of the bus. each bus master requests the bus by means of a bus request signal. the bus arbiter determines priorities at the prescribed timing, and permits use of the bus by means of a bus request acknowledge signal. the selected bus master then takes possession of the bus and begins its operation. 6.7.2 operation the bus arbiter detects the bus masters? bus request signals, and if the bus is requested, sends a bus request acknowledge signal to the bus master making the request. if there are bus requests from both bus masters, the bus request acknowledge signal is sent to the one with the higher priority. when a bus master receives the bus request acknowledge signal, it takes possession of the bus until that signal is canceled. the order of priority of the bus masters is as follows: (high) dtc > cpu (low)
160 6.7.3 bus transfer timing even if a bus request is received from a bus master with a higher priority than that of the bus master that has acquired the bus and is currently operating, the bus is not necessarily transferred immediately. there are specific times at which each bus master can relinquish the bus. cpu: the cpu is the lowest-priority bus master, and if a bus request is received from the dtc, the bus arbiter transfers the bus to the dtc. the timing for transfer of the bus is as follows: the bus is transferred at a break between bus cycles. however, if a bus cycle is executed in discrete operations, as in the case of a longword-size access, the bus is not transferred between the operations. see appendix a.5, bus states during instruction execution, for timings at which the bus is not transferred. if the cpu is in sleep mode, it transfers the bus immediately. dtc: the dtc sends the bus arbiter a request for the bus when an activation request is generated. the dtc does not release the bus until it has completed a series of processing operations.
161 section 7 data transfer controller 7.1 overview the h8s/2169 or h8s/2149 includes a data transfer controller (dtc). the dtc can be activated by an interrupt or software, to transfer data. 7.1.1 features ? transfer possible over any number of channels ? transfer information is stored in memory ? one activation source can trigger a number of data transfers (chain transfer) ? wide range of transfer modes ? normal, repeat, and block transfer modes available ? incrementing, decrementing, and fixing of transfer source and destination addresses can be selected ? direct specification of 16-mbyte address space possible ? 24-bit transfer source and destination addresses can be specified ? transfer can be set in byte or word units ? a cpu interrupt can be requested for the interrupt that activated the dtc ? an interrupt request can be issued to the cpu after one data transfer ends ? an interrupt request can be issued to the cpu after all specified data transfers have ended ? activation by software is possible ? module stop mode can be set ? the initial setting enables dtc registers to be accessed. dtc operation is halted by setting module stop mode
162 7.1.2 block diagram figure 7.1 shows a block diagram of the dtc. the dtc? register information is stored in the on-chip ram*. a 32-bit bus connects the dtc to the on-chip ram (1 kbyte), enabling 32-bit/1-state reading and writing of the dtc register information. note: * when the dtc is used, the rame bit in syscr must be set to 1. interrupt request interrupt controller dtc internal address bus dtc activation request control logic register information mra mrb cra crb dar sar cpu interrupt request on-chip ram internal data bus legend: mra, mrb: dtc mode registers a and b cra, crb: dtc transfer count registers a and b sar: dtc source address register dar: dtc destination address register dtcera to dtcere: dtc enable registers a to e dtvecr: dtc vector register dtcera to dtcere dtvecr figure 7.1 block diagram of dtc
163 7.1.3 register configuration table 7.1 summarizes the dtc registers. table 7.1 dtc registers name abbreviation r/w initial value address * 1 dtc mode register a mra * 2 undefined * 3 dtc mode register b mrb * 2 undefined * 3 dtc source address register sar * 2 undefined * 3 dtc destination address register dar * 2 undefined * 3 dtc transfer count register a cra * 2 undefined * 3 dtc transfer count register b crb * 2 undefined * 3 dtc enable registers dtcer r/w h'00 h'feee to h'fef2 dtc vector register dtvecr r/w h'00 h'fef3 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. registers within the dtc cannot be read or written to directly. 3. allocated to on-chip ram addresses h'ec00 to h'efff as register information. they cannot be located in external memory space. when the dtc is used, do not clear the rame bit in syscr to 0.
164 7.2 register descriptions 7.2.1 dtc mode register a (mra) 7 sm1 6 sm0 5 dm1 4 dm0 3 md1 0 sz 2 md0 1 dts bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined mra is an 8-bit register that controls the dtc operating mode. bits 7 and 6?ource address mode 1 and 0 (sm1, sm0): these bits specify whether sar is to be incremented, decremented, or left fixed after a data transfer. bit 7 bit 6 sm1 sm0 description 0 sar is fixed 1 0 sar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 sar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) bits 5 and 4?estination address mode 1 and 0 (dm1, dm0): these bits specify whether dar is to be incremented, decremented, or left fixed after a data transfer. bit 5 bit 4 dm1 dm0 description 0 dar is fixed 1 0 dar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 dar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1)
165 bits 3 and 2?tc mode (md1, md0): these bits specify the dtc transfer mode. bit 3 bit 2 md1 md0 description 0 0 normal mode 1 repeat mode 1 0 block transfer mode 1 bit 1?tc transfer mode select (dts): specifies whether the source side or the destination side is set to be a repeat area or block area, in repeat mode or block transfer mode. bit 1 dts description 0 destination side is repeat area or block area 1 source side is repeat area or block area bit 0?tc data transfer size (sz): specifies the size of data to be transferred. bit 0 sz description 0 byte-size transfer 1 word-size transfer
166 7.2.2 dtc mode register b (mrb) 7 chne 6 disel 5 4 3 0 2 1 bit initial value read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined mrb is an 8-bit register that controls the dtc operating mode. bit 7?tc chain transfer enable (chne): specifies chain transfer. in chain transfer, multiple data transfers can be performed consecutively in response to a single transfer request. with data transfer for which chne is set to 1, there is no determination of the end of the specified number of transfers, clearing of the interrupt source flag, or clearing of dtcer. bit 7 chne description 0 end of dtc data transfer (activation waiting state is entered) 1 dtc chain transfer (new register information is read, then data is transferred) bit 6?tc interrupt select (disel): specifies whether interrupt requests to the cpu are disabled or enabled after a data transfer. bit 6 disel description 0 after a data transfer ends, the cpu interrupt is disabled unless the transfer counter is 0 (the dtc clears the interrupt source flag of the activating interrupt to 0) 1 after a data transfer ends, the cpu interrupt is enabled (the dtc does not clear the interrupt source flag of the activating interrupt to 0) bits 5 to 0?eserved: in the chip these bits have no effect on dtc operation, and should always be written with 0.
167 7.2.3 dtc source address register (sar) 23 22 21 20 19 43210 bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined sar is a 24-bit register that designates the source address of data to be transferred by the dtc. for word-size transfer, specify an even source address. 7.2.4 dtc destination address register (dar) 23 22 21 20 19 43210 bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined dar is a 24-bit register that designates the destination address of data to be transferred by the dtc. for word-size transfer, specify an even destination address. 7.2.5 dtc transfer count register a (cra) 15 14 13 12 11109876543210 crah cral bit initial value unde- fined read/write unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined cra is a 16-bit register that designates the number of times data is to be transferred by the dtc. in normal mode, the entire cra register functions as a 16-bit transfer counter (1 to 65,536). it is decremented by 1 every time data is transferred, and transfer ends when the count reaches h'0000. in repeat mode or block transfer mode, cra is divided into two parts: the upper 8 bits (crah) and the lower 8 bits (cral). crah holds the number of transfers while cral functions as an 8- bit transfer counter (1 to 256). cral is decremented by 1 every time data is transferred, and the contents of crah are transferred when the count reaches h'00. this operation is repeated.
168 7.2.6 dtc transfer count register b (crb) 15 14 13 12 11109876543210 bit initial value unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined unde- fined read/write crb is a 16-bit register that designates the number of times data is to be transferred by the dtc in block transfer mode. it functions as a 16-bit transfer counter (1 to 65,536) that is decremented by 1 every time data is transferred, and transfer ends when the count reaches h'0000. 7.2.7 dtc enable registers (dtcer) 7 dtce7 0 r/w 6 dtce6 0 r/w 5 dtce5 0 r/w 4 dtce4 0 r/w 3 dtce3 0 r/w 0 dtce0 0 r/w 2 dtce2 0 r/w 1 dtce1 0 r/w bit initial value read/write the dtc enable registers comprise five 8-bit readable/writable registers, dtcera to dtcere, with bits corresponding to the interrupt sources that can activate the dtc. these bits enable or disable dtc service for the corresponding interrupt sources. the dtc enable registers are initialized to h'00 by a reset and in hardware standby mode. bit n?tc activation enable (dtcen) bit n dtcen description 0 dtc activation by interrupt is disabled (initial value) [clearing conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end 1 dtc activation by interrupt is enabled [holding condition] when the disel bit is 0 and the specified number of transfers have not ended (n = 7 to 0) a dtce bit can be set for each interrupt source that can activate the dtc. the correspondence between interrupt sources and dtce bits is shown in table 7.4, together with the vector number generated by the interrupt controller in each case.
169 for dtce bit setting, read/write operations must be performed using bit-manipulation instructions such as bset and bclr. for the initial setting only, however, when multiple activation sources are set at one time, it is possible to disable interrupts and write after executing a dummy read on the relevant register. 7.2.8 dtc vector register (dtvecr) 7 swdte 0 r/(w) * 6 dtvec6 0 r/w 5 dtvec5 0 r/w 4 dtvec4 0 r/w 3 dtvec3 0 r/w 0 dtvec0 0 r/w 2 dtvec2 0 r/w 1 dtvec1 0 r/w a value of 1 can always be written to the swdte bit, but 0 can only be written after 1 is read. bit initial value read/write note: * dtvecr is an 8-bit readable/writable register that enables or disables dtc activation by software, and sets a vector number for the software activation interrupt. dtvecr is initialized to h'00 by a reset and in hardware standby mode. bit 7?tc software activation enable (swdte): specifies enabling or disabling of dtc software activation. to clear the swdte bit by software, read swdte when set to 1, then write 0 in the bit. bit 7 swdte description 0 dtc software activation is disabled [clearing condition] when the disel bit is 0 and the specified number of transfers have not ended (initial value) 1 dtc software activation is enabled [holding conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end ? during software-activated data transfer bits 6 to 0?tc software activation vectors 6 to 0 (dtvec6 to dtvec0): these bits specify a vector number for dtc software activation. the vector address is h'0400 + (vector number) << 1 (where << 1 indicates a 1-bit left shift). for example, if dtvec6 to dtvec0 = h'10, the vector address is h'0420.
170 7.2.9 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp14 bit in mstpcr is set to 1, the dtc operation stops at the end of the bus cycle and a transition is made to module stop mode. note that 1 cannot be written to the mstp14 bit when the dtc is being activated. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 6?odule stop (mstp14): specifies the dtc module stop mode. mstpcrh bit 6 mstp14 description 0 dtc module stop mode is cleared (initial value) 1 dtc module stop mode is set
171 7.3 operation 7.3.1 overview when activated, the dtc reads register information that is already stored in memory and transfers data on the basis of that register information. after the data transfer, it writes updated register information back to memory. pre-storage of register information in memory makes it possible to transfer data over any required number of channels. setting the chne bit to 1 makes it possible to perform a number of transfers with a single activation. figure 7.2 shows a flowchart of dtc operation. start read dtc vector next transfer read register information data transfer write register information clear activation flag chne = 1? end no no yes yes transfer counter = 0 or disel = 1? clear dtcer interrupt exception handling figure 7.2 flowchart of dtc operation
172 the dtc transfer mode can be normal mode, repeat mode, or block transfer mode. the 24-bit sar designates the dtc transfer source address and the 24-bit dar designates the transfer destination address. after each transfer, sar and dar are independently incremented, decremented, or left fixed. table 7.2 outlines the functions of the dtc. table 7.2 dtc functions address registers transfer mode activation source transfer source transfer destination ? normal mode ? one transfer request transfers one byte or one word ? memory addresses are incremented or decremented by 1 or 2 ? up to 65,536 transfers possible ? repeat mode ? one transfer request transfers one byte or one word ? memory addresses are incremented or decremented by 1 or 2 ? after the specified number of transfers (1 to 256), the initial state resumes and operation continues ? block transfer mode ? one transfer request transfers a block of the specified size ? block size is from 1 to 256 bytes or words ? up to 65,536 transfers possible ? a block area can be designated at either the source or destination ? irq ? frt ici, oci ? 8-bit timer cmi ? host interface ibf ? sci txi or rxi ? a/d converter adi ? iic iici ? software 24 bits 24 bits
173 7.3.2 activation sources the dtc operates when activated by an interrupt or by a write to dtvecr by software (software activation). an interrupt request can be directed to the cpu or dtc, as designated by the corresponding dtcer bit. the interrupt request is directed to the dtc when the corresponding bit is set to 1, and to the cpu when the bit is cleared to 0. at the end of one data transfer (or the last of the consecutive transfers in the case of chain transfer) the interrupt source or the corresponding dtcer bit is cleared. table 7.3 shows activation sources and dtcer clearing. the interrupt source flag for rxi0, for example, is the rdrf flag in sci0. table 7.3 activation sources and dtcer clearing activation source when disel bit is 0 and specified number of transfers have not ended when disel bit is 1 or specified number of transfers have ended software activation swdte bit cleared to 0 ? swdte bit held at 1 ? interrupt request sent to cpu interrupt activation ? corresponding dtcer bit held at 1 ? activation source flag cleared to 0 ? corresponding dtcer bit cleared to 0 ? activation source flag held at 1 ? activation source interrupt request sent to cpu figure 7.3 shows a block diagram of activation source control. for details see section 5, interrupt controller.
174 on-chip supporting module irq interrupt dtvecr selection circuit interrupt controller cpu dtc dtcer clear control select interrupt request source flag cleared clear clear request interrupt mask figure 7.3 block diagram of dtc activation source control when an interrupt has been designated a dtc activation source, existing cpu mask level and interrupt controller priorities have no effect. if there is more than one activation source at the same time, the dtc is activated in accordance with the default priorities. 7.3.3 dtc vector table figure 7.4 shows the correspondence between dtc vector addresses and register information. table 7.4 shows the correspondence between activation sources, vector addresses, and dtcer bits. when the dtc is activated by software, the vector address is obtained from: h'0400 + dtvecr[6:0] << 1 (where << 1 indicates a 1-bit left shift). for example, if dtvecr is h'10, the vector address is h'0420. the dtc reads the start address of the register information from the vector address set for each activation source, and then reads the register information from that start address. the register information can be placed at predetermined addresses in the on-chip ram. the start address of the register information should be an integral multiple of four. the configuration of the vector address is the same in both normal and advanced modes, a 2-byte unit being used in both cases. these two bytes specify the lower bits of the address in the on-chip ram.
175 register information start address register information chain transfer dtc vector address figure 7.4 correspondence between dtc vector address and register information table 7.4 interrupt sources, dtc vector addresses, and corresponding dtces interrupt source origin of interrupt source vector number vector address dtce * priority write to dtvecr software dtvecr (decimal indication) h'0400 + dtvecr [6:0] << 1 high irq0 external pin 16 h'0420 dtcea7 irq1 17 h'0422 dtcea6 irq2 18 h'0424 dtcea5 irq3 19 h'0426 dtcea4 adi (a/d conversion end) a/d 28 h'0438 dtcea3 icia (frt input capture a) frt 48 h'0460 dtcea2 icib (frt input capture b) 49 h'0462 dtcea1 ocia (frt output compare a) 52 h'0468 dtcea0 ocib (frt output compare b) 54 h'046a dtceb7 cmia0 (tmr0 compare-match a) tmr0 64 h'0480 dtceb2 cmib0 (tmr0 compare-match b) 65 h'0482 dtceb1 cmia1 (tmr1 compare-match a) tmr1 68 h'0488 dtceb0 cmib1 (tmr1 compare-match b) 69 h'048a dtcec7 cmiay (tmry compare-match a) tmry 72 h'0490 dtcec6 cmiby (tmry compare-match b) 73 h'0492 dtcec5 ibf1 (idr1 reception completed) hif 76 h'0498 dtcec4 ibf2 (idr2 reception completed) 77 h'049a dtcec3 rxi0 (reception completed 0) sci channel 0 81 h'04a2 dtcec2 txi0 (transmit data empty 0) 82 h'04a4 dtcec1
176 interrupt source origin of interrupt source vector number vector address dtce * priority rxi1 (reception completed 1) sci channel 1 85 h'04aa dtcec0 txi1 (transmit data empty 1) 86 h'04ac dtced7 rxi2 (reception completed 2) sci channel 2 89 h'04b2 dtced6 txi2 (transmit data empty 2) 90 h'04b4 dtced5 iici0 (iic0 1-byte transmission/ reception completed) iic0 92 h'04b8 dtced4 iici1 (iic1 1-byte transmission/ reception completed) iic1 94 h'04bc dtced3 erri (transfer error etc.) lpc 104 h'04d8 dtcee3 ibfi1 (idr1 reception completed) 105 h'04da dtcee2 ibfi2 (idr2 reception completed) 106 h'04dc dtcee1 ibfi3 (idr3 reception completed) 107 h'04de dtcee0 low note: * dtce bits with no corresponding interrupt are reserved, and should be written with 0. 7.3.4 location of register information in address space figure 7.5 shows how the register information should be located in the address space. locate the mra, sar, mrb, dar, cra, and crb registers, in that order, from the start address of the register information (vector address contents). in chain transfer, locate the register information in consecutive areas. locate the register information in the on-chip ram (addresses: h'ffec00 to h'ffefff).
177 register information start address chain transfer register information for 2nd transfer in chain transfer mra sar mrb dar cra crb 4 bytes lower address cra crb register information mra 0 123 sar mrb dar figure 7.5 location of dtc register information in address space 7.3.5 normal mode in normal mode, one operation transfers one byte or one word of data. from 1 to 65,536 transfers can be specified. once the specified number of transfers have ended, a cpu interrupt can be requested. table 7.5 lists the register information in normal mode and figure 7.6 shows memory mapping in normal mode. table 7.5 register information in normal mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register a cra transfer count dtc transfer count register b crb not used
178 transfer sar dar figure 7.6 memory mapping in normal mode 7.3.6 repeat mode in repeat mode, one operation transfers one byte or one word of data. from 1 to 256 transfers can be specified. once the specified number of transfers have ended, the initial address register state specified by the transfer counter and repeat area resumes and transfer is repeated. in repeat mode the transfer counter does not reach h'00, and therefore cpu interrupts cannot be requested when disel = 0. table 7.6 lists the register information in repeat mode and figure 7.7 shows memory mapping in repeat mode. table 7.6 register information in repeat mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register ah crah holds number of transfers dtc transfer count register al cral transfer count dtc transfer count register b crb not used
179 transfer repeat area sar or dar dar or sar figure 7.7 memory mapping in repeat mode 7.3.7 block transfer mode in block transfer mode, one operation transfers one block of data. either the transfer source or the transfer destination is specified as a block area. the block size is 1 to 256. when the transfer of one block ends, the initial state of the block size counter and the address register specified in the block area is restored. the other address register is successively incremented or decremented, or left fixed. from 1 to 65,536 transfers can be specified. once the specified number of transfers have ended, a cpu interrupt is requested. table 7.7 lists the register information in block transfer mode and figure 7.8 shows memory mapping in block transfer mode. table 7.7 register information in block transfer mode name abbreviation function dtc source address register sar transfer source address dtc destination address register dar transfer destination address dtc transfer count register ah crah holds block size dtc transfer count register al cral block size count dtc transfer count register b crb transfer counter
180 transfer sar or dar dar or sar block area first block nth block figure 7.8 memory mapping in block transfer mode
181 7.3.8 chain transfer setting the chne bit to 1 enables a number of data transfers to be performed consecutively in response to a single transfer request. sar, dar, cra, crb, mra, and mrb, which define data transfers, can be set independently. figure 7.9 shows memory mapping for chain transfer. source source destination destination dtc vector address register information start address register information chne = 1 register information chne = 0 figure 7.9 memory mapping in chain transfer in the case of transfer with chne set to 1, an interrupt request to the cpu is not generated at the end of the specified number of transfers or by setting of the disel bit to 1, and the interrupt source flag for the activation source is not affected.
182 7.3.9 operation timing figures 7.10 to 7.12 show examples of dtc operation timing. dtc activation request dtc request address vector read transfer information read transfer information write data transfer read write figure 7.10 dtc operation timing (normal mode or repeat mode) read write read write data transfer transfer information write transfer information read vector read dtc activation request dtc request address figure 7.11 dtc operation timing (block transfer mode, with?lock?ize?f?)
183 read write read write address dtc activation request dtc request data transfer data transfer transfer information write transfer information write transfer information read transfer information read vector read figure 7.12 dtc operation timing (chain transfer) 7.3.10 number of dtc execution states table 7.8 lists execution phases for a single dtc data transfer, and table 7.9 shows the number of states required for each execution phase. table 7.8 dtc execution phases mode vector read i register information read/write j data read k data write l internal operation m normal 1 6 1 1 3 repeat 1 6 1 1 3 block transfer 1 6 n n 3 n: block size (initial setting of crah and cral)
184 table 7.9 number of states required for each execution phase object of access on- chip ram on- chip rom internal i/o registers external devices bus width 32 16 8 16 8 8 16 16 access states 112223 23 execution phase vector read s i 1 4 6+2m 2 3+m register information read/write s j 1 byte data read s k 112223+m23+m word data read s k 11424 6+2m 2 3+m byte data write s l 112223+m23+m word data write s l 11424 6+2m 2 3+m internal operation s m 111111 11 the number of execution states is calculated from the formula below. note that s means the sum of all transfers activated by one activation event (the number for which the chne bit is set to one, plus 1). number of execution states = i ?s i + s (j ?s j + k ?s k + l ?s l ) + m ?s m for example, when the dtc vector address table is located in on-chip rom, normal mode is set, and data is transferred from the on-chip rom to an internal i/o register, the time required for the dtc operation is 13 states. the time from activation to the end of the data write is 10 states.
185 7.3.11 procedures for using the dtc activation by interrupt: the procedure for using the dtc with interrupt activation is as follows: 1. set the mra, mrb, sar, dar, cra, and crb register information in the on-chip ram. 2. set the start address of the register information in the dtc vector address. 3. set the corresponding bit in dtcer to 1. 4. set the enable bits for the interrupt sources to be used as the activation sources to 1. the dtc is activated when an interrupt used as an activation source is generated. 5. after the end of one data transfer, or after the specified number of data transfers have ended, the dtce bit is cleared to 0 and a cpu interrupt is requested. if the dtc is to continue transferring data, set the dtce bit to 1. activation by software: the procedure for using the dtc with software activation is as follows: 1. set the mra, mrb, sar, dar, cra, and crb register information in the on-chip ram. 2. set the start address of the register information in the dtc vector address. 3. check that the swdte bit is 0. 4. write 1 in the swdte bit and the vector number to dtvecr. 5. check the vector number written to dtvecr. 6. after the end of one data transfer, if the disel bit is 0 and a cpu interrupt is not requested, the swdte bit is cleared to 0. if the dtc is to continue transferring data, set the swdte bit to 1. when the disel bit is 1, or after the specified number of data transfers have ended, the swdte bit is held at 1 and a cpu interrupt is requested.
186 7.3.12 examples of use of the dtc normal mode: an example is shown in which the dtc is used to receive 128 bytes of data via the sci. 1. set mra to fixed source address (sm1 = sm0 = 0), incrementing destination address (dm1 = 1, dm0 = 0), normal mode (md1 = md0 = 0), and byte size (sz = 0). the dts bit can have any value. set mrb for one data transfer by one interrupt (chne = 0, disel = 0). set the sci rdr address in sar, the start address of the ram area where the data will be received in dar, and 128 (h'0080) in cra. crb can be set to any value. 2. set the start address of the register information at the dtc vector address. 3. set the corresponding bit in dtcer to 1. 4. set the sci to the appropriate receive mode. set the rie bit in scr to 1 to enable the reception complete (rxi) interrupt. since the generation of a receive error during the sci reception operation will disable subsequent reception, the cpu should be enabled to accept receive error interrupts. 5. each time reception of one byte of data ends on the sci, the rdrf flag in ssr is set to 1, an rxi interrupt is generated, and the dtc is activated. the receive data is transferred from rdr to ram by the dtc. dar is incremented and cra is decremented. the rdrf flag is automatically cleared to 0. 6. when cra becomes 0 after the 128 data transfers have ended, the rdrf flag is held at 1, the dtce bit is cleared to 0, and an rxi interrupt request is sent to the cpu. the interrupt handling routine should perform wrap-up processing.
187 software activation: an example is shown in which the dtc is used to transfer a block of 128 bytes of data by means of software activation. the transfer source address is h'1000 and the destination address is h'2000. the vector number is h'60, so the vector address is h'04c0. 1. set mra to incrementing source address (sm1 = 1, sm0 = 0), incrementing destination address (dm1 = 1, dm0 = 0), block transfer mode (md1 = 1, md0 = 0), and byte size (sz = 0). the dts bit can have any value. set mrb for one block transfer by one interrupt (chne = 0). set the transfer source address (h'1000) in sar, the destination address (h'2000) in dar, and 128 (h'8080) in cra. set 1 (h'0001) in crb. 2. set the start address of the register information at the dtc vector address (h'04c0). 3. check that the swdte bit in dtvecr is 0. check that there is currently no transfer activated by software. 4. write 1 to the swdte bit and the vector number (h'60) to dtvecr. the write data is h'e0. 5. read dtvecr again and check that it is set to the vector number (h'60). if it is not, this indicates that the write failed. this is presumably because an interrupt occurred between steps 3 and 4 and led to a different software activation. to activate this transfer, go back to step 3. 6. if the write was successful, the dtc is activated and a block of 128 bytes of data is transferred. 7. after the transfer, an swdtend interrupt occurs. the interrupt handling routine should clear the swdte bit to 0 and perform other wrap-up processing.
188 7.4 interrupts an interrupt request is issued to the cpu when the dtc finishes the specified number of data transfers, or a data transfer for which the disel bit was set to 1. in the case of interrupt activation, the interrupt set as the activation source is generated. these interrupts to the cpu are subject to cpu mask level and interrupt controller priority level control. in the case of activation by software, a software-activated data transfer end interrupt (swdtend) is generated. when the disel bit is 1 and one data transfer has ended, or the specified number of transfers have ended, after data transfer ends, the swdte bit is held at 1 and an swdtend interrupt is generated. the interrupt handling routine should clear the swdte bit to 0. when the dtc is activated by software, an swdtend interrupt is not generated during a data transfer wait or during data transfer even if the swdte bit is set to 1. 7.5 usage notes module stop: when the mstp14 bit in mstpcr is set to 1, the dtc clock stops, and the dtc enters the module stop state. however, 1 cannot be written in the mstp14 bit while the dtc is operating. when the dtc is placed in the module stop state, the dtcer registers must all be in the cleared state when the mstp14 bit is set to 1. on-chip ram: the mra, mrb, sar, dar, cra, and crb registers are all located in on-chip ram. when the dtc is used, the rame bit in syscr must not be cleared to 0. dtce bit setting: for dtce bit setting, read/write operations must be performed using bit- manipulation instructions such as bset and bclr. for the initial setting only, however, when multiple activation sources are set at one time, it is possible to disable interrupts and write after executing a dummy read on the relevant register.
189 section 8 i/o ports 8.1 overview the h8s/2149 has ten i/o ports (ports 1 to 6, 8, 9, a, and b), and one input-only port (port 7). for additional ports c, d, e, f, and g in h8s/2169, see section 8.13 additional overview for h8s/2169. tables 8.1 is a summary of the port functions. the pins of each port also have other functions. each port includes a data direction register (ddr) that controls input/output (not provided for the input-only port) and data registers (dr, odr) that store output data. ports 1 to 3, 6, a, and b have a built-in mos input pull-up function. for ports a and b, the on/off status of the mos input pull-up is controlled by ddr and odr. ports 1 to 3 and 6 have a mos input pull-up control register (pcr), in addition to ddr and dr, to control the on/off status of the mos input pull-ups. ports 1 to 6, 8, 9, a, and b can drive a single ttl load and 30 pf capacitive load. all the i/o ports can drive a darlington transistor when in output mode. ports 1, 2, and 3 can drive an led (10 ma sink current). port a input and output use by the vccb power supply, which is independent of the v cc power supply. when the vccb voltage is 5v, the pins on port a will be 5-v tolerant. pa4 to pa7 of port a have bus-buffer drive capability. p52 in port 5 and p97 in port 9 are nmos push-pull outputs. p52 and p97 are thus 5-v tolerant, with dc characteristics that are dependent on the v cc voltage.
190 table 8.1 h8s/2169 or h8s/2149 port functions expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 1 ? 8-bit i/o port ? built-in mos input pull-ups ? led drive capability p17 to p10/ a7 to a0/ pw7 to pw0 lower address output (a7 to a0) when ddr = 0 (after reset): input port when ddr = 1: lower address output (a7 to a0) or pwm timer output (pw7 to pw0) i/o port also functioning as pwm timer output (pw7 to pw0) port 2 ? 8-bit i/o port ? built-in mos input pull-ups ? led drive capability p27/a15/pw15/ cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 upper address output (a15 to a8) when ddr = 0 (after reset): input port or timer connection output (cblank) when ddr = 1: upper address output (a15 to a8), pwm timer output (pw15 to pw12), timer connection output (cblank), or output ports (p27 to p24) i/o port also functioning as pwm timer output (pw15 to pw8) and timer connection output (cblank) port 3 ? 8-bit i/o port ? built-in mos input pull-ups ? led drive capability p37/d15/hdb7/ serirq p36/d14/hdb6/ lclk p35/d13/hdb5/ lreset p34/d12/hdb4/ lframe p33 to p30/ d11 to d8/ hdb3 to hdb0/ lad3 to lad0 data bus input/output (d15 to d8) i/o port also functioning as xbs data bus input/output (hdb7 to hdb0) and lpc input/output (serirq, lclk, lreset , lframe , lad3 to lad0)
191 expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 4 ? 8-bit i/o port p47/pwx1 p46/pwx0 p45/tmri1/ hirq12/csynci p44/tmo1/ hirq1/hsynco p43/tmci1/ hirq11/hsynci p42/tmri0/ sck2/sda1 p41/tmo0/ rxd2/irrxd p40/tmci0/ txd2/irtxd i/o port also functioning as 14-bit pwm timer output (pwx1, pwx0), 8-bit timer 0 and 1 input/output (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection input/output (hsynco, csynci, hsynci), sci2 input/output (txd2, rxd2, sck2), irda interface input/output (irtxd, irrxd), and i 2 c bus interface 1 input/output (sda1) i/o port also functioning as 14-bit pwm timer output (pwx1, pwx0), 8-bit timer 0 and 1 input/ output (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection input/output (hsynco, csynci, hsynci), host interface (xbs) host cpu interrupt request output (hirq12, hirq1, hirq11), sci2 input/ output (txd2, rxd2, sck2), irda interface input/output (irtxd, irrxd), and i 2 c bus interface 1 input/output (sda1) port 5 ? 3-bit i/o port p52/sck0/scl0 p51/rxd0 p50/txd0 i/o port also functioning as sci0 input/output (txd0, rxd0, sck0) and i 2 c bus interface 0 input/output (scl0) port 6 ? 8-bit i/o port p67/ irq7 /tmox/ kin7 /cin7 p66/ irq6 /ftob/ kin6 /cin6 p65/ftid/ kin5 / cin5 p64/ftic/ kin4 / cin4/clampo p63/ftib/ kin3 / cin3/vfbacki p62/ftia/tmiy/ kin2 /cin2/ vsynci p61/ftoa/ kin1 / cin1/vsynco p60/ftci/tmix/ kin0 /cin0/ hfbacki i/o port also functioning as external interrupt input ( irq7 , irq6 ), frt input/output (ftci, ftoa, ftia, ftib, ftic, ftid, ftob), 8-bit timer x and y input/output (tmox, tmix, tmiy), timer connection input/output (clampo, vfbacki, vsynci, vsynco, hfbacki), key-sense interrupt input ( kin7 to kin0 ), and expansion a/d converter input (cin7 to cin0)
192 expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 7 ? 8-bit input port p77/an7/da1 p76/an6/da0 p75/an5 p74/an4 p73/an3 p72/an2 p71/an1 p70/an0 input port also functioning as a/d converter analog input (an7 to an0) and d/a converter analog output (da1, da0) port 8 ? 7-bit i/o port p86/ irq5 /sck1/ scl1 p85/ irq4 /rxd1 p84/ irq3 /txd1 p83/ lpcpd p82/hifsd/ clkrun p81/ cs2 /ga20 p80/ha0/ pme i/o port also functioning as external interrupt input ( irq5 , irq4 , irq3 ), sci1 input/ output (txd1, rxd1, sck1), and i 2 c bus interface 1 input/output (scl1) i/o port also functioning as external interrupt input ( irq5 , irq4 , irq3 ), sci1 input/output (txd1, rxd1, sck1), host interface (xbs) control input/output ( cs2 , ga20, ha0, hifsd), host interface (lpc) control input/output ( lpcpd , clkrun , ga20, pme ), and i 2 c bus interface 1 input/output (scl1) port 9 ? 8-bit i/o port p97/ wait /sda0 i/o port also functioning as expanded data bus control input ( wait ) and i 2 c bus interface 0 input/output (sda0) i/o port also functioning as i 2 c bus interface 0 input/output (sda0) p96/?excl when ddr = 0: input port or excl input when ddr = 1 (after reset): output when ddr = 0 (after reset): input port or excl input when ddr = 1: ?output p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior expanded data bus control output ( as / ios , hwr , rd ) i/o port also functioning as host interface (xbs) control input ( cs1 , iow , ior )
193 expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port 9 ? 8-bit i/o port p92/ irq0 p91/ irq1 i/o port also functioning as external interrupt input ( irq0 , irq1 ) p90/ lwr / irq2 / adtrg / ecs 2 i/o port also functioning as expanded data bus control output ( lwr ), external interrupt input ( irq2 ), and a/d converter external trigger input ( adtrg ) i/o port also functioning as external interrupt input ( irq2 ), a/d converter external trigger input ( adtrg ), and host interface (xbs) control input ( ecs2 ) port a ? 8-bit i/o port pa7/a23/ kin15 / cin15/ps2cd pa6/a22/ kin14 / cin14/ps2cc pa5/a21/ kin13 / cin13/ps2bd pa4/a20/ kin12 / cin12/ps2bc pa3/a19/ kin11 / cin11/ps2ad pa2/a18/ kin10 / cin10/ps2ac pa1/a17/ kin9 / cin9 pa0/a16/ kin8 / cin8 i/o port also functioning as key- sense interrupt input ( kin15 to kin8 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac) i/o port also functioning as address output (a23 to a16), key-sense interrupt input ( kin15 to kin8 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac) i/o port also functioning as key-sense interrupt input ( kin15 to kin8 ), expansion a/d converter input (cin15 to cin8), and keyboard buffer controller input/output (ps2cd, ps2cc, ps2bd, ps2bc, ps2ad, ps2ac)
194 expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port b ? 8-bit i/o port pb7/d7/ wue7 pb6/d6/ wue6 pb5/d5/ wue5 pb4/d4/ wue4 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 pb1/d1/ wue1 / hirq4/lsci pb0/d0/ wue0 / hirq3/ lsmi in 8-bit bus mode (abw = 1): i/o port also functioning as wakeup event interrupt input ( wue7 to wue0 ) in 16-bit bus mode (abw = 0): data bus input/output (d7 to d0) i/o port also functioning as host interface (xbs) control input/output ( cs3 , cs4 , hirq3, hirq4), host interface (lpc) control input/output (lsci, lsmi ), and wakeup event interrupt input ( wue7 to wue0 )
195 8.2 port 1 8.2.1 overview port 1 is an 8-bit i/o port. port 1 pins also function as address bus output function, and as 8-bit pwm output pins (pw7 to pw0). port 1 functions change according to the operating mode. port 1 has a built-in mos input pull-up function that can be controlled by software. figure 8.1 shows the port 1 pin configuration. p17/a7/pw7 p16/a6/pw6 p15/a5/pw5 p14/a4/pw4 p13/a3/pw3 p12/a2/pw2 p11/a1/pw1 p10/a0/pw0 port 1 port 1 pins a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) pin functions in mode 1 a7 (output)/p17 (input)/pw7 (output) a6 (output)/p16 (input)/pw6 (output) a5 (output)/p15 (input)/pw5 (output) a4 (output)/p14 (input)/pw4 (output) a3 (output)/p13 (input)/pw3 (output) a2 (output)/p12 (input)/pw2 (output) a1 (output)/p11 (input)/pw1 (output) a0 (output)/p10 (input)/pw0 (output) pin functions in modes 2 and 3 (expe = 1) p17 (i/o)/pw7 (output) p16 (i/o)/pw6 (output) p15 (i/o)/pw5 (output) p14 (i/o)/pw4 (output) p13 (i/o)/pw3 (output) p12 (i/o)/pw2 (output) p11 (i/o)/pw1 (output) p10 ( i/o ) /pw0 ( output ) pin functions in modes 2 and 3 (expe = 0) figure 8.1 port 1 pin functions
196 8.2.2 register configuration table 8.2 shows the port 1 register configuration. table 8.2 port 1 registers name abbreviation r/w initial value address * port 1 data direction register p1ddr w h'00 h'ffb0 port 1 data register p1dr r/w h'00 h'ffb2 port 1 mos pull-up control register p1pcr r/w h'00 h'ffac note: * lower 16 bits of the address. port 1 data direction register (p1ddr) 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w bit initial value read/write p1ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 1. p1ddr cannot be read; if it is, an undefined value will be returned. p1ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the address output pins maintain their output state in a transition to software standby mode. ? mode 1 the corresponding port 1 pins are address outputs, regardless of the p1ddr setting. in hardware standby mode, the address outputs go to the high-impedance state. ? modes 2 and 3 (expe = 1) the corresponding port 1 pins are address outputs or pwm outputs when p1ddr bits are set to 1, and input ports when cleared to 0. ? modes 2 and 3 (expe = 0) the corresponding port 1 pins are output ports or pwm outputs when p1ddr bits are set to 1, and input ports when cleared to 0.
197 port 1 data register (p1dr) 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w bit initial value r/w p1dr is an 8-bit readable/writable register that stores output data for the port 1 pins (p17 to p10). if a port 1 read is performed while p1ddr bits are set to 1, the p1dr values are read directly, regardless of the actual pin states. if a port 1 read is performed while p1ddr bits are cleared to 0, the pin states are read. p1dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 1 mos pull-up control register (p1pcr) 7 p17pcr 0 r/w 6 p16pcr 0 r/w 5 p15pcr 0 r/w 4 p14pcr 0 r/w 3 p13pcr 0 r/w 0 p10pcr 0 r/w 2 p12pcr 0 r/w 1 p11pcr 0 r/w bit initial value r/w p1pcr is an 8-bit readable/writable register that controls the port 1 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3, the mos input pull-up is turned on when a p1pcr bit is set to 1 while the corresponding p1ddr bit is cleared to 0 (input port setting). p1pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
198 8.2.3 pin functions in each mode mode 1: in mode 1, port 1 pins automatically function as address outputs. the port 1 pin functions are shown in figure 8.2. a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) port 1 figure 8.2 port 1 pin functions (mode 1) modes 2 and 3 (expe = 1): in modes 2 and 3 (when expe = 1), port 1 pins function as address outputs, pwm outputs, or input ports, and input or output can be specified on a bit-by-bit basis. when a bit in p1ddr is set to 1, the corresponding pin functions as an address output or pwm output, and when cleared to 0, as an input port. the port 1 pin functions are shown in figure 8.3. a7 (output) a6 (output) a5 (output) a4 (output) a3 (output) a2 (output) a1 (output) a0 (output) port 1 when p1ddr = 1 and pwoera = 0 p17 (input) p16 (input) p15 (input) p14 (input) p13 (input) p12 (input) p11 (input) p10 (input) when p1ddr = 0 pw7 (output) pw6 (output) pw5 (output) pw4 (output) pw3 (output) pw2 (output) pw1 (output) pw0 (output) when p1ddr = 1 and pwoera = 1 figure 8.3 port 1 pin functions (modes 2 and 3 (expe = 1))
199 modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 1 pins function as pwm outputs or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p1ddr is set to 1, the corresponding pin functions as a pwm output or output port, and when cleared to 0, as an input port. the port 1 pin functions are shown in figure 8.4. p17 (i/o) p16 (i/o) p15 (i/o) p14 (i/o) p13 (i/o) p12 (i/o) p11 (i/o) p10 (i/o) port 1 p1n: input pin when p1ddr = 0, output pin when p1ddr = 1 and pwoera = 0 pw7 (output) pw6 (output) pw5 (output) pw4 (output) pw3 (output) pw2 (output) pw1 (output) pw0 (output) when p1ddr = 1 and pwoera = 1 figure 8.4 port 1 pin functions (modes 2 and 3 (expe = 0)) 8.2.4 mos input pull-up function port 1 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3, and can be specified as on or off on a bit-by- bit basis. when a p1ddr bit is cleared to 0 in mode 2 or 3, setting the corresponding p1pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.4 summarizes the mos input pull-up states.
200 table 8.3 mos input pull-up states (port 1) mode reset hardware standby mode software standby mode in other operations 1 off off off off 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p1ddr = 0 and p1pcr = 1; otherwise off. 8.3 port 2 8.3.1 overview port 2 is an 8-bit i/o port. port 2 pins also function as address bus output function, 8-bit pwm output pins (pw15 to pw8), and the timer connection output pin (cblank). port 2 functions change according to the operating mode. port 2 has a built-in mos input pull-up function that can be controlled by software. figure 8.5 shows the port 2 pin configuration.
201 p27/a15/pw15/cblank p26/a14/pw14 p25/a13/pw13 p24/a12/pw12 p23/a11/pw11 p22/a10/pw10 p21/a9/pw9 p20/a8/pw8 port 2 port 2 pins a15 (output) a14 (output) a13 (output) a12 (output) a11 (output) a10 (output) a9 (output) a8 (output) pin functions in mode 1 a15 (output)/p27 (i/o)/pw15 (output)/cblank (output) a14 (output)/p26 (i/o)/pw14 (output) a13 (output)/p25 (i/o)/pw13 (output) a12 (output)/p24 (i/o)/pw12 (output) a11 (output)/p23 (input)/pw11 (output) a10 (output)/p22 (input)/pw10 (output) a9 (output)/p21 (input)/pw9 (output) a8 (output)/p20 (input)/pw8 (output) pin functions in modes 2 and 3 (expe = 1) p27 (i/o)/pw15 (output)/cblank (output) p26 (i/o)/pw14 (output) p25 (i/o)/pw13 (output) p24 (i/o)/pw12 (output) p23 (i/o)/pw11 (output) p22 (i/o)/pw10 (output) p21 (i/o)/pw9 (output) p20 ( i/o ) /pw8 ( output ) pin functions in modes 2 and 3 (expe = 0) figure 8.5 port 2 pin functions
202 8.3.2 register configuration table 8.4 shows the port 2 register configuration. table 8.4 port 2 registers name abbreviation r/w initial value address * port 2 data direction register p2ddr w h'00 h'ffb1 port 2 data register p2dr r/w h'00 h'ffb3 port 2 mos pull-up control register p2pcr r/w h'00 h'ffad note: * lower 16 bits of the address. port 2 data direction register (p2ddr) 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w bit initial value read/write p2ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 2. p2ddr cannot be read; if it is, an undefined value will be returned. p2ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the address output pins maintain their output state in a transition to software standby mode. ? mode 1 the corresponding port 2 pins are address outputs, regardless of the p2ddr setting. in hardware standby mode, the address outputs go to the high-impedance state. ? modes 2 and 3 (expe = 1) the corresponding port 2 pins are address outputs or pwm outputs when p2ddr bits are set to 1, and input ports when cleared to 0. p27 to p24 are switched from address outputs to output ports by setting the iose bit to 1. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting, but to ensure normal access to external space, p27 should not be set as an on-chip supporting module output pin when port 2 pins are used as address output pins.
203 ? modes 2 and 3 (expe = 0) the corresponding port 2 pins are output ports or pwm outputs when p2ddr bits are set to 1, and input ports when cleared to 0. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting. port 2 data register (p2dr) 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w bit initial value r/w p2dr is an 8-bit readable/writable register that stores output data for the port 2 pins (p27 to p20). if a port 2 read is performed while p2ddr bits are set to 1, the p2dr values are read directly, regardless of the actual pin states. if a port 2 read is performed while p2ddr bits are cleared to 0, the pin states are read. p2dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 2 mos pull-up control register (p2pcr) 7 p27pcr 0 r/w 6 p26pcr 0 r/w 5 p25pcr 0 r/w 4 p24pcr 0 r/w 3 p23pcr 0 r/w 0 p20pcr 0 r/w 2 p22pcr 0 r/w 1 p21pcr 0 r/w bit initial value r/w p2pcr is an 8-bit readable/writable register that controls the port 2 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3, the mos input pull-up is turned on when a p2pcr bit is set to 1 while the corresponding p2ddr bit is cleared to 0 (input port setting). p2pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
204 8.3.3 pin functions in each mode mode 1: in mode 1, port 2 pins automatically function as address outputs. the port 2 pin functions are shown in figure 8.6. a15 (output) a14 (output) a13 (output) a12 (output) a11 (output) a10 (output) a9 (output) a8 (output) port 2 figure 8.6 port 2 pin functions (mode 1) modes 2 and 3 (expe = 1): in modes 2 and 3 (when expe = 1), port 2 pins function as address outputs, pwm outputs, or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p2ddr is set to 1, the corresponding pin functions as an address output or pwm output, and when cleared to 0, as an input port. p27 to p24 are switched from address outputs to output ports by setting the iose bit to 1. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting, but to ensure normal access to external space, p27 should not be set as an on-chip supporting module output pin when port 2 pins are used as address output pins. the port 2 pin functions are shown in figure 8.7. a15 (output)/p27 (output) a14 (output)/p26 (output) a13 (output)/p25 (output) a12 (output)/p24 (output) a11 (output) a10 (output) a9 (output) a8 (output) port 2 when p2ddr = 1 and pwoerb = 0 p27 (input)/cblank (output) p26 (input) p25 (input) p24 (input) p23 (input) p22 (input) p21 (input) p20 (input) when p2ddr = 0 pw15 (output)/cblank (output) pw14 (output) pw13 (output) pw12 (output) pw11 (output) pw10 (output) pw9 (output) pw8 (output) when p2ddr = 1 and pwoerb = 1 figure 8.7 port 2 pin functions (modes 2 and 3 (expe = 1))
205 modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 2 pins function as pwm outputs (timer connection output (cblank)) or i/o ports, and input or output can be specified on a bit-by-bit basis. when a bit in p2ddr is set to 1, the corresponding pin functions as a pwm output or output port, and when cleared to 0, as an input port. p27 can be used as an on-chip supporting module output pin regardless of the p27ddr setting. the port 2 pin functions are shown in figure 8.8. p27 (i/o)/cblank (output) p26 (i/o) p25 (i/o) p24 (i/o) p23 (i/o) p22 (i/o) p21 (i/o) p20 (i/o) port 2 p2n: input pin when p2ddr = 0, output pin when p2ddr = 1 and pwoerb = 0 pw15 (output)/cblank (output) pw14 (output) pw13 (output) pw12 (output) pw11 (output) pw10 (output) pw9 (output) pw8 (output) when p2ddr = 1 and pwoerb = 1 figure 8.8 port 2 pin functions (modes 2 and 3 (expe = 0)) 8.3.4 mos input pull-up function port 2 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3, and can be specified as on or off on a bit-by- bit basis. when a p2ddr bit is cleared to 0 in mode 2 or 3, setting the corresponding p2pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.5 summarizes the mos input pull-up states.
206 table 8.5 mos input pull-up states (port 2) mode reset hardware standby mode software standby mode in other operations 1 off off off off 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p2ddr = 0 and p2pcr = 1; otherwise off.
207 8.4 port 3 8.4.1 overview port 3 is an 8-bit i/o port. port 3 pins also have host interface (lpc) input/output (serirq, lclk, lreset , lframe , lad3 to lad0), host interface (xbs) data bus input/output (hdb7 to hdb0), and as data bus i/o pins. port 3 functions change according to the operating mode. port 3 has a built-in mos input pull-up function that can be controlled by software. figure 8.9 shows the port 3 pin configuration. p37/d15/hdb7/serirq p36/d14/hdb6/lclk p35/d13/hdb5/ lreset p34/d12/hdb4/ lframe p33/d11/hdb3/lad3 p32/d10/hdb2/lad2 p31/d9/hdb1/lad1 p30/d8/hdb0/lad0 port 3 port 3 pins d15 (i/o) d14 (i/o) d13 (i/o) d12 (i/o) d11 (i/o) d10 (i/o) d9 (i/o) d8 (i/o) pin functions in modes 1, 2 and 3 (expe = 1) p37 (i/o)/hdb7 (i/o)/serirq (i/o) p36 (i/o)/hdb6 (i/o)/lclk (input) p35 (i/o)/hdb5 (i/o)/ lreset (input) p34 (i/o)/hdb4 (i/o)/ lframe (input) p33 (i/o)/hdb3 (i/o)/lad3 (i/o) p32 (i/o)/hdb2 (i/o)/lad2 (i/o) p31 (i/o)/hdb1 (i/o)/lad1 (i/o) p30 (i/o)/hdb0 (i/o)/lad0 (i/o) pin functions in modes 2 and 3 (expe = 0) figure 8.9 port 3 pin functions
208 8.4.2 register configuration table 8.6 shows the port 3 register configuration. table 8.6 port 3 registers name abbreviation r/w initial value address * port 3 data direction register p3ddr w h'00 h'ffb4 port 3 data register p3dr r/w h'00 h'ffb6 port 3 mos pull-up control register p3pcr r/w h'00 h'ffae note: * lower 16 bits of the address. port 3 data direction register (p3ddr) 7 p37ddr 0 w 6 p36ddr 0 w 5 p35ddr 0 w 4 p34ddr 0 w 3 p33ddr 0 w 0 p30ddr 0 w 2 p32ddr 0 w 1 p31ddr 0 w bit initial value read/write p3ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 3. p3ddr cannot be read; if it is, an undefined value will be returned. p3ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. ? modes 1, 2, and 3 (expe = 1) the input/output direction specified by p3ddr is ignored, and pins automatically function as data i/o pins. after a reset, and in hardware standby mode or software standby mode, the data i/o pins go to the high-impedance state. ? modes 2 and 3 (expe = 0) the corresponding port 3 pins are output ports when p3ddr bits are set to 1, and input ports when cleared to 0.
209 port 3 data register (p3dr) 7 p37dr 0 r/w 6 p36dr 0 r/w 5 p35dr 0 r/w 4 p34dr 0 r/w 3 p33dr 0 r/w 0 p30dr 0 r/w 2 p32dr 0 r/w 1 p31dr 0 r/w bit initial value read/write p3dr is an 8-bit readable/writable register that stores output data for the port 3 pins (p37 to p30). if a port 3 read is performed while p3ddr bits are set to 1, the p3dr values are read directly, regardless of the actual pin states. if a port 3 read is performed while p3ddr bits are cleared to 0, the pin states are read. p3dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 3 mos pull-up control register (p3pcr) 7 p37pcr 0 r/w 6 p36pcr 0 r/w 5 p35pcr 0 r/w 4 p34pcr 0 r/w 3 p33pcr 0 r/w 0 p30pcr 0 r/w 2 p32pcr 0 r/w 1 p31pcr 0 r/w bit initial value read/write p3pcr is an 8-bit readable/writable register that controls the port 3 built-in mos input pull-ups on a bit-by-bit basis. in modes 2 and 3 (when expe = 0), the mos input pull-up is turned on when a p3pcr bit is set to 1 while the corresponding p3ddr bit is cleared to 0 (input port setting). p3pcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. the mos input pull-up function cannot be used when the host interface is enabled.
210 8.4.3 pin functions in each mode modes 1, 2, and 3 (expe = 1): in modes 1, 2, and 3 (when expe = 1), port 3 pins automatically function as data i/o pins. it is recommended that all the host interface enable bits multiplexed as port 3 bits in single-chip mode (bit hi12e in syscr2 and bits lpc3e to lpc1e in hicr0) be cleared to 0. the port 3 pin functions are shown in figure 8.10. d15 (i/o) d14 (i/o) d13 (i/o) d12 (i/o) d11(i/o) d10 (i/o) d9 (i/o) d8 (i/o) port 3 figure 8.10 port 3 pin functions (modes 1, 2, and 3 (expe = 1)) modes 2 and 3 (expe = 0): in modes 2 and 3 (when expe = 0), port 3 functions as host interface (lpc) i/o pins (serirq, lclk, lreset , lframe, lad3 to lad0), as host interface (xbs) data bus i/o pins (hdb7 to hdb0), or as an i/o port. the priority order for pin function settings is: lpc, xbs, i/o port. when at least one of bits lpc3e to lpc1e is set to 1 in hicr0, port 3 functions as host interface (lpc) i/o pins. even in this state, it is recommended that the hi12e bit be cleared to 0 in syscr2. p3dr and p3ddr should be cleared to h'00. when the hi12e bit is set to 1 in syscr2, port 3 functions as the host interface (xbs) data bus. in this case, p3dr and p3ddr should be cleared to h'00. when bits lpc3e to lpc1e and hi12e are all cleared to 0, port 3 functions as an i/o port, and input or output can be specified on a bit-by-bit basis. when a bit in p3ddr is set to 1, the corresponding pin functions as an output port, and when cleared to 0, as an input port. the port 3 pin functions are shown in figure 8.11.
211 p37 (i/o)/hdb7 (i/o)/serirq (i/o) p36 (i/o)/hdb6 (i/o)/lclk (input) p35 (i/o)/hdb5 (i/o)/ lreset (input) p34 (i/o)/hdb4 (i/o)/ lframe (input) p33 (i/o)/hdb3 (i/o)/lad3 (i/o) p32 (i/o)/hdb2 (i/o)/lad2 (i/o) p31 (i/o)/hdb1 (i/o)/lad1 (i/o) p30 (i/o)/hdb0 (i/o)/lad0 (i/o) port 3 figure 8.11 port 3 pin functions (modes 2 and 3 (expe = 0)) 8.4.4 mos input pull-up function port 3 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 2 and 3 (when expe = 0), and can be specified as on or off on a bit-by-bit basis. when a p3ddr bit is cleared to 0 in mode 2 or 3 (when expe = 0), setting the corresponding p3pcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.7 summarizes the mos input pull-up states. table 8.7 mos input pull-up states (port 3) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 (expe = 1) off off off off 2, 3 (expe = 0) off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p3ddr = 0 and p3pcr = 1; otherwise off.
212 8.5 port 4 8.5.1 overview port 4 is an 8-bit i/o port. port 4 pins also function as 14-bit pwm output pins (pwx1, pwx0), 8-bit timer 0 and 1 (tmr0, tmr1) i/o pins (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection i/o pins (csynci, hsynci, hsynco), sci2 i/o pins (txd2, rxd2, sck2), irda interface i/o pins (irtxd, irrxd), host interface (xbs) output pins (hirq12, hirq1, hirq11), and the iic1 i/o pin (sda1). port 4 pin functions are the same in all operating modes. figure 8.12 shows the port 4 pin configuration. p47 (i/o)/pwx1 (output) p46 (i/o)/pwx0 (output) p45 (i/o)/tmri1 (input)/hirq12 (output)/csynci (input) p44 (i/o)/tmo1 (output)/hirq1 (output)/hsynco (output) p43 (i/o)/tmci1 (input)/hirq11 (output)/hcynci (input) p42 (i/o)/tmri0 (input)/sck2 (i/o)/sda1 (i/o) p41 (i/o)/tmo0 (output)/rxd2 (input)/irrxd (input) p40 (i/o)/tmci0 (input)/txd2 (output)/irtxd (output) port 4 port 4 pins figure 8.12 port 4 pin functions 8.5.2 register configuration table 8.8 shows the port 4 register configuration. table 8.8 port 4 registers name abbreviation r/w initial value address * port 4 data direction register p4ddr w h'00 h'ffb5 port 4 data register p4dr r/w h'00 h'ffb7 note: * lower 16 bits of the address.
213 port 4 data direction register (p4ddr) 7 p47ddr 0 w 6 p46ddr 0 w 5 p45ddr 0 w 4 p44ddr 0 w 3 p43ddr 0 w 0 p40ddr 0 w 2 p42ddr 0 w 1 p41ddr 0 w bit initial value read/write p4ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 4. p4ddr cannot be read; if it is, an undefined value will be returned. when a bit in p4ddr is set to 1, the corresponding pin functions as an output port, and when cleared to 0, as an input port. p4ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. as 14-bit pwm and sci2 are initialized in software standby mode, the pin states are determined by the tmr0, tmr1, xbs, iic1, p4ddr, and p4dr specifications. port 4 data register (p4dr) 7 p47dr 0 r/w 6 p46dr 0 r/w 5 p45dr 0 r/w 4 p44dr 0 r/w 3 p43dr 0 r/w 0 p40dr 0 r/w 2 p42dr 0 r/w 1 p41dr 0 r/w bit initial value read/write p4dr is an 8-bit readable/writable register that stores output data for the port 4 pins (p47 to p40). if a port 4 read is performed while p4ddr bits are set to 1, the p4dr values are read directly, regardless of the actual pin states. if a port 4 read is performed while p4ddr bits are cleared to 0, the pin states are read. p4dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. 8.5.3 pin functions port 4 pins also function as 14-bit pwm output pins (pwx1, pwx0), 8-bit timer 0 and 1 (tmr0, tmr1) i/o pins (tmci0, tmri0, tmo0, tmci1, tmri1, tmo1), timer connection i/o pins (csynci, hsynci, hsynco), sci2 i/o pins (txd2, rxd2, sck2), irda interface i/o pins (irtxd, irrxd), host interface (xbs) output pins (hirq12, hirq1, hirq11), and the iic1 i/o pin (sda1). the port 4 pin functions are shown in table 8.9.
214 table 8.9 port 4 pin functions pin selection method and pin functions p47/pwx1 the pin function is switched as shown below according to the combination of bit oeb in dacr of 14-bit pwm, and bit p47ddr. oeb 0 1 p47ddr 0 1 pin function p47 input pin p47 output pin pwx1 output pin p46/pwx0 the pin function is switched as shown below according to the combination of bit oea in dacr of 14-bit pwm, and bit p46ddr. oea 0 1 p46ddr 0 1 pin function p46 input pin p46 output pin pwx0 output pin p45/tmri1/ hirq12/csynci the pin function is switched as shown below according to the combination of bit hi12e in syscr2, and bit p45ddr. p45ddr 0 1 hi12e 0 1 pin function p45 input pin p45 output pin hirq12 output pin tmri1 input pin, csynci input pin when bits cclr1 and cclr0 in tcr1 of tmr1 are set to 1, this pin is used as the tmri1 input pin. it can also be used as the csynci input pin. p44/tmo1/ hirq1/hsynco the pin function is switched as shown below according to the combination of bit hi12e in syscr2, bits os3 to os0 in tcsr of tmr1, bit hoe in tconro of the timer connection function, and bit p44ddr. hoe 0 1 os3 to os0 all 0 not all 0 p44ddr 0 1 hi12e 0 1 pin function p44 input pin p44 output pin hirq1 output pin tmo1 output pin hsynco output pin
215 pin selection method and pin functions p43/tmci1/ hirq11/hsynci the pin function is switched as shown below according to the combination of bit hi12e in syscr2 and bit p43ddr. p43ddr 0 1 hi12e 0 1 pin function p43 input pin p43 output pin hirq11 output pin tmci1 input pin, hsynci input pin when an external clock is selected with bits cks2 to cks0 in tcr1 of tmr1, this pin is used as the tmci1 input pin. it can also be used as the hsynci input pin. p42/tmri0/ sck2/sda1 the pin function is switched as shown below according to the combination of bit ice in iccr of iic1, bits cke1 and cke0 in scr of sci2, bit c/ a in smr of sci2, and bit p42ddr. ice 0 1 cke1 0 1 0 c/ a 010 cke0 0 1 0 p42ddr 0 1 pin function p42 input pin p42 output pin sck2 output pin sck2 output pin sck2 input pin sda1 i/o pin tmri0 input pin when this pin is used as the sda1 i/o pin, bits cke1 and cke0 in scr of sci2 and bit c/ a in smr of sci2 must all be cleared to 0. sda1 is an nmos- only output, and has direct bus drive capability. when bits cclr1 and cclr0 in tcr0 of tmr0 are set to 1, this pin is used as the tmri0 input pin.
216 pin selection method and pin functions p41/tmo0/rxd2/ irrxd the pin function is switched as shown below according to the combination of bits os3 to os0 in tcsr of tmr0, bit re in scr of sci2 and bit p41ddr. os3 to os0 all 0 not all 0 re 0 1 0 p41ddr 0 1 pin function p41 input pin p41 output pin rxd2/irrxd input pin tmo0 output pin when this pin is used as the tmo0 output pin, bit re in scr of sci2 must be cleared to 0. p40/tmci0/txd2/ irtxd the pin function is switched as shown below according to the combination of bit te in scr of sci2 and bit p40ddr. te 0 1 p40ddr 0 1 pin function p40 input pin p40 output pin txd2/irtxd output pin tmci0 input pin when an external clock is selected with bits cks2 to cks0 in tcr0 of tmr0, this pin is used as the tmci0 input pin.
217 8.6 port 5 8.6.1 overview port 5 is a 3-bit i/o port. port 5 pins also function as sci0 i/o pins (txd0, rxd0, sck0), and the iic0 i/o pin (scl0). p52 and sck0 are nmos push-pull outputs, and scl0 is an nmos open- drain output. port 5 pin functions are the same in all operating modes. figure 8.13 shows the port 5 pin configuration. p52 (i/o)/sck0 (i/o)/scl0 (i/o) p51 (i/o)/rxd0 (input) p50 (i/o)/txd0 (output) port 5 port 5 pins figure 8.13 port 5 pin functions 8.6.2 register configuration table 8.10 shows the port 5 register configuration. table 8.10 port 5 registers name abbreviation r/w initial value address * port 5 data direction register p5ddr w h'f8 h'ffb8 port 5 data register p5dr r/w h'f8 h'ffba note: * lower 16 bits of the address.
218 port 5 data direction register (p5ddr) 7 1 6 1 5 1 4 1 3 1 0 p50ddr 0 w 2 p52ddr 0 w 1 p51ddr 0 w bit initial value read/write p5ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 5. p5ddr cannot be read; if it is, an undefined value will be returned. bits 7 to 3 are reserved. setting a p5ddr bit to 1 makes the corresponding port 5 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p5ddr is initialized to h'f8 by a reset and in hardware standby mode. it retains its prior state in software standby mode. as sci0 is initialized, the pin states are determined by the iic0 iccr, p5ddr, and p5dr specifications. port 5 data register (p5dr) 7 1 6 1 5 1 4 1 3 1 0 p50dr 0 r/w 2 p52dr 0 r/w 1 p51dr 0 r/w bit initial value read/write p5dr is an 8-bit readable/writable register that stores output data for the port 5 pins (p52 to p50). if a port 5 read is performed while p5ddr bits are set to 1, the p5dr values are read directly, regardless of the actual pin states. if a port 5 read is performed while p5ddr bits are cleared to 0, the pin states are read. bits 7 to 3 are reserved; they cannot be modified and are always read as 1. p5dr is initialized to h'f8 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
219 8.6.3 pin functions port 5 pins also function as sci0 i/o pins (txd0, rxd0, sck0) and the iic0 i/o pin (scl0). the port 5 pin functions are shown in table 8.11. table 8.11 port 5 pin functions pin selection method and pin functions p52/sck0/scl0 the pin function is switched as shown below according to the combination of bits cke1 and cke0 in scr of sci0, bit c/ a in smr of sci0, bit ice in iccr of iic0, and bit p52ddr. ice 0 1 cke1 0 1 0 c/ a 010 cke0 0 1 0 p52ddr 0 1 pin function p52 input pin p52 output pin sck0 output pin sck0 output pin sck0 input pin scl0 i/o pin when this pin is used as the scl0 i/o pin, bits cke1 and cke0 in scr of sci0 and bit c/ a in smr of sci0 must all be cleared to 0. scl0 is an nmos open-drain output, and has direct bus drive capability. when set as the p52 output pin or sck0 output pin, this pin is an nmos push- pull output. p51/rxd0 the pin function is switched as shown below according to the combination of bit re in scr of sci0 and bit p51ddr. re 0 1 p51ddr 0 1 pin function p51 input pin p51 output pin rxd0 input pin p50/txd0 the pin function is switched as shown below according to the combination of bit te in scr of sci0 and bit p50ddr. te 0 1 p50ddr 0 1 pin function p50 input pin p50 output pin txd0 output pin
220 8.7 port 6 8.7.1 overview port 6 is an 8-bit i/o port. port 6 pins also function as the 16-bit free-running timer (frt) i/o pins (ftoa, ftob, ftia to ftid, ftci), timer x (tmrx) i/o pins (tmox, tmix), the timer y (tmry) input pin (tmiy), timer connection i/o pins (hfbacki, vsynci, vsynco, vfbacki, clampo), key-sense interrupt input pins ( kin7 to kin0 ), expansion a/d converter input pins (cin7 to cin0), and external interrupt input pins ( irq7 , irq6 ). the port 6 input level can be switched in four stages. port 6 pin functions are the same in all operating modes. figure 8.14 shows the port 6 pin configuration. p67 (i/o)/tmox (output)/ kin7 (input)/cin7 (input)/ irq7 (input) p66 (i/o)/ftob (output)/ kin6 (input)/cin6 (input)/ irq6 (input) p65 (i/o)/ftid (input)/ kin5 (input)/cin5 (input) p64 (i/o)/ftic (input)/ kin4 (input)/cin4 (input)/clampo (output) p63 (i/o)/ftib (input)/ kin3 (input)/cin3 (input)/vfbacki (input) p62 (i/o)/ftia (input)/ kin2 (input)/cin2 (input)/vsynci (input)/tmiy (input) p61 (i/o)/ftoa (output)/ kin1 (input)/cin1 (input)/vsynco (output) p60 (i/o)/ftci (input)/ kin0 (input)/cin0 (input)/hfbacki (input)/tmix (input) port 6 port 6 pins figure 8.14 port 6 pin functions
221 8.7.2 register configuration table 8.12 shows the port 6 register configuration. table 8.12 port 6 registers name abbreviation r/w initial value address * 1 port 6 data direction register p6ddr w h'00 h'ffb9 port 6 data register p6dr r/w h'00 h'ffbb port 6 mos pull-up control register kmpcr r/w h'00 h'fff2 * 2 system control register syscr2 r/w h'00 h'ff83 notes: 1. lower 16 bits of the address. 2. kmpcr has the same address as ticrr/tcoray of tmrx/tmry. to select kmpcr, set the hie bit to 1 in syscr and set the mstp2 bit to 0 in mstpcrl. port 6 data direction register (p6ddr) 7 p67ddr 0 w 6 p66ddr 0 w 5 p65ddr 0 w 4 p64ddr 0 w 3 p63ddr 0 w 0 p60ddr 0 w 2 p62ddr 0 w 1 p61ddr 0 w bit initial value read/write p6ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 6. p6ddr cannot be read; if it is, an undefined value will be returned. setting a p6ddr bit to 1 makes the corresponding port 6 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p6ddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
222 port 6 data register (p6dr) 7 p67dr 0 r/w 6 p66dr 0 r/w 5 p65dr 0 r/w 4 p64dr 0 r/w 3 p63dr 0 r/w 0 p60dr 0 r/w 2 p62dr 0 r/w 1 p61dr 0 r/w bit initial value read/write p6dr is an 8-bit readable/writable register that stores output data for the port 6 pins (p67 to p60). if a port 6 read is performed while p6ddr bits are set to 1, the p6dr values are read directly, regardless of the actual pin states. if a port 6 read is performed while p6ddr bits are cleared to 0, the pin states are read. p6dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 6 mos pull-up control register (kmpcr) bit 76543210 km7pcr km6pcr km5pcr km4pcr km3pcr km2pcr km1pcr km0pcr initial value 00000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w kmpcr is an 8-bit readable/writable register that controls the port 6 built-in mos input pull-ups on a bit-by-bit basis. the mos input pull-up is turned on when a kmpcr bit is set to 1 while the corresponding p6ddr bit is cleared to 0 (input port setting). kmpcr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
223 system control register 2 (syscr2) bit 76543210 kwul1 kwul0 p6pue sde cs4e cs3e hi12e initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w syscr2 is an 8-bit readable/writable register that controls port 6 input level selection and the operation of host interface functions. only bits 7, 6, and 5 are described here. see section 18a.2.2, system control register 2 (syscr2), for information on bits 4 to 0. syscr2 is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 6?ey wakeup level 1 and 0 (kwul1, kwul0): the port 6 input level setting can be changed by software, using these bits. the setting of these bits also changes the input level of the pin functions multiplexed with port 6. bit 7 bit 6 kwul1 kwul0 description 0 0 standard input level is selected as port 6 input level (initial value) 1 input level 1 is selected as port 6 input level 1 0 input level 2 is selected as port 6 input level 1 input level 3 is selected as port 6 input level bit 5?ort 6 input pull-up extra (p6pue): controls and selects the current specification for the port 6 mos input pull-up function connected by means of kmpcr settings. bit 5 p6pue description 0 standard current specification is selected for port 6 mos input pull-up function (initial value) 1 current-limit specification is selected for port 6 mos input pull-up function
224 8.7.3 pin functions port 6 pins also function as the 16-bit free-running timer (frt) i/o pins (ftoa, ftob, ftia to ftid, ftci), timer x (tmrx) i/o pins (tmox, tmix), the timer y (tmry) input pin (tmiy), timer connection i/o pins (hfbacki, vsynci, vsynco, vfbacki, clampo), key-sense interrupt input pins ( kin7 to kin0 ), expansion a/d input pins (cin7 to cin0), and interrupt input pins ( irq7 , irq6 ). the port 6 input level can be switched in four stages. the port 6 pin functions are shown in table 8.13. table 8.13 port 6 pin functions pin selection method and pin functions p67/tmox/ irq7 / kin7 /cin7 the pin function is switched as shown below according to the combination of bits os3 to os0 in tcsr of tmrx and bit p67ddr. os3 to os0 all 0 not all 0 p67ddr 0 1 pin function p67 input pin p67 output pin tmox output pin irq7 input pin, kin7 input pin, cin7 input pin this pin is used as the irq7 input pin when bit irq7e is set to 1 in ier. it can always be used as the kin7 or cin7 input pin. p66/ftob/ irq6 / kin6 /cin6 the pin function is switched as shown below according to the combination of bit oeb in tocr of the frt and bit p66ddr. oeb 0 1 p66ddr 0 1 pin function p66 input pin p66 output pin ftob output pin irq6 input pin, kin6 input pin, cin6 input pin this pin is used as the irq6 input pin when bit irq6e is set to 1 in ier. it can always be used as the kin6 or cin6 input pin. p65/ftid/ kin5 / p65ddr 0 1 cin5 pin function p65 input pin p65 output pin ftid input pin, kin5 input pin, cin5 input pin this pin can always be used as the ftid, kin5 , or cin5 input pin.
225 pin selection method and pin functions p64/ftic/ kin4 / cin4/clampo the pin function is switched as shown below according to the combination of bit cloe in tconro of the timer connection function and bit p64ddr. cloe 0 1 p64ddr 0 1 pin function p64 input pin p64 output pin clampo output pin ftic input pin, kin4 input pin, cin4 input pin this pin can always be used as the ftic, kin4 , or cin4 input pin. p63/ftib/ kin3 / p63ddr 0 1 cin3/vfbacki pin function p63 input pin p63 output pin ftib input pin, vfbacki input pin, kin3 input pin, cin3 input pin this pin can always be used as the ftib, kin3 , cin3, or vfbacki input pin. p62/ftia/tmiy/ p62ddr 0 1 kin2 /cin2/ pin function p62 input pin p62 output pin vsynci ftia input pin, vsynci input pin, tmiy input pin, kin2 input pin, cin2 input pin this pin can always be used as the ftia, tmiy, kin2 , cin2, or vsynci input pin. p61/ftoa/ kin1 / cin1/vsynco the pin function is switched as shown below according to the combination of bit oea in tocr of the frt, bit voe in tconro of the timer connection function, and bit p61ddr. voe 0 1 oea 0 1 0 p61ddr 0 1 pin function p61 input pin p61 output pin ftoa output pin vsynco output pin kin1 input pin, cin1 input pin when this pin is used as the vsynco pin, bit oea in tocr of the frt must be cleared to 0. this pin can always be used as the kin1 or cin1 input pin.
226 pin selection method and pin functions p60/ftci/tmix/ p60ddr 0 1 kin0 /cin0/ pin function p60 input pin p60 output pin hfbacki ftci input pin, hfbacki input pin, tmix input pin, kin0 input pin, cin0 input pin this pin is used as the ftci input pin when an external clock is selected with bits cks1 and cks0 in tcr of the frt. it can always be used as the tmix, kin0 , cin0, or hfbacki input pin. 8.7.4 mos input pull-up function port 6 has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in any operating mode, and can be specified as on or off on a bit-by-bit basis. when a p6ddr bit is cleared to 0, setting the corresponding kmpcr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up current specification can be changed by means of the p6pue bit. when a pin is designated as an on-chip supporting module output pin, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.14 summarizes the mos input pull-up states. table 8.14 mos input pull-up states (port 6) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when p6ddr = 0 and kmpcr = 1; otherwise off.
227 8.8 port 7 8.8.1 overview port 7 is an 8-bit input only port. port 7 pins also function as the a/d converter analog input pins (an0 to an7) and d/a converter analog output pins (da0, da1). port 7 functions are the same in all operating modes. figure 8.15 shows the port 7 pin configuration. p77 (input)/an7 (input)/da1 (output) p76 (input)/an6 (input)/da0 (output) p75 (input)/an5 (input) p74 (input)/an4 (input) p73 (input)/an3 (input) p72 (input)/an2 (input) p71 (input)/an1 (input) p70 (input)/an0 (input) port 7 port 7 pins figure 8.15 port 7 pin functions 8.8.2 register configuration table 8.15 shows the port 7 register configuration. port 7 is an input-only port, and does not have a data direction register or data register. table 8.15 port 7 registers name abbreviation r/w initial value address * 1 port 7 input data register p7pin r undefined h'ffbe * 2 notes: 1. lower 16 bits of the address. 2. p7pin has the same address as pbddr.
228 port 7 input data register (p7pin) 7 p77pin * r 6 p76pin * r 5 p75pin * r 4 p74pin * r 3 p73pin * r 0 p70pin * r 2 p72pin * r 1 p71pin * r bit initial value read/write note: * determined by the state of pins p77 to p70. when a p7pin read is performed, the pin states are always read. p7pin has the same address as pbddr; if a write is performed, data will be written into pbddr and the port b setting will be changed. 8.8.3 pin functions port 7 pins also function as the a/d converter analog input pins (an0 to an7) and d/a converter analog output pins (da0, da1).
229 8.9 port 8 8.9.1 overview port 8 is an 8-bit i/o port. port 8 pins also function as sci1 i/o pins (txd1, rxd1, sck1), the iic1 i/o pin (scl1), host interface (xbs) i/o pins ( cs2 , ga20, ha0, hifsd), host interface (lpc) i/o pins ( pme , ga20, clkrun , lpcpd ), and interrupt input pins ( irq5 to irq3 ). port 8 pin functions are the same in all operating modes except host interface function. figure 8.16 shows the port 8 pin configuration. p86 (i/o)/ irq5 (input)/sck1 (i/o)/scl1 (i/o) p85 (i/o)/ irq4 (input)/rxd1 (input) p84 (i/o)/ irq3 (input)/txd1 (output) p83 (i/o)/ lpcpd (input) p82 (i/o)/hifsd (input)/ clkrun (i/o) p81 (i/o)/ cs2 (input)/ga20 (i/o) p80 (i/o)/ha0 (input)/ pme (i/o) port 8 port 8 pins figure 8.16 port 8 pin functions 8.9.2 register configuration table 8.16 summarizes the port 8 registers. table 8.16 port 8 registers name abbreviation r/w initial value address * 1 port 8 data direction register p8ddr w h'80 h'ffbd * 2 port 8 data register p8dr r/w h'80 h'ffbf notes: 1. lower 16 bits of the address. 2. p8ddr has the same address as pbpin.
230 port 8 data direction register (p8ddr) bit 76543210 p86ddr p85ddr p84ddr p83ddr p82ddr p81ddr p80ddr initial value 1 0 0 0 0 0 0 0 read/write w w w w w w w p8ddr is a 7-bit write-only register, the individual bits of which specify input or output for the pins of port 8. p8ddr has the same address as pbpin, and if read, the port b state will be returned. setting a p8ddr bit to 1 makes the corresponding port 8 pin an output pin, while clearing the bit to 0 makes the pin an input pin. p8ddr is initialized to h'80 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port 8 data register (p8dr) bit 76543210 p86dr p85dr p84dr p83dr p82dr p81dr p80dr initial value 1 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w p8dr is a 7-bit readable/writable register that stores output data for the port 8 pins (p86 to p80). if a port 8 read is performed while p8ddr bits are set to 1, the p8dr values are read directly, regardless of the actual pin states. if a port 8 read is performed while p8ddr bits are cleared to 0, the pin states are read. p8dr is initialized to h'80 by a reset and in hardware standby mode. it retains its prior state in software standby mode. 8.9.3 pin functions port 8 pins also function as sci1 i/o pins (txd1, rxd1, sck1), the iic1 i/o pin (scl1), host interface (hif) i/o pins ( cs2 , ga20, ha0, hifsd), host interface (lpc) i/o pins ( pme , ga20, clkrun , lpcpd ), and interrupt input pins ( irq5 to irq3 ). the port 8 pin functions are shown in table 8.17.
231 table 8.17 port 8 pin functions pin selection method and pin functions p86/ irq5 /sck1/ scl1 the pin function is switched as shown below according to the combination of bits cke1 and cke0 in scr of sci1, bit c/ a in smr of sci1, bit ice in iccr of iic1, and bit p86ddr. ice 0 1 cke1 0 1 0 c/ a 010 cke0 0 1 0 p86ddr 0 1 pin function p86 input pin p86 output pin sck1 output pin sck1 output pin sck1 input pin scl1 i/o pin irq5 input pin when the irq5e bit in ier is set to 1, this pin is used as the irq5 input pin. when this pin is used as the scl1 i/o pin, bits cke1 and cke0 in scr of sci1 and bit c/ a in smr of sci1 must all be cleared to 0. scl1 is an nmos- only output, and has direct bus drive capability. p85/ irq4 /rxd1 the pin function is switched as shown below according to the combination of bit re in scr of sci1 and bit p85ddr. re 0 1 p85ddr 0 1 pin function p85 input pin p85 output pin rxd1 input pin irq4 input pin when the irq4e bit in ier is set to 1, this pin is used as the irq4 input pin. p84/ irq3 /txd1 the pin function is switched as shown below according to the combination of bit te in scr of sci1 and bit p84ddr. te 0 1 p84ddr 0 1 pin function p84 input pin p84 output pin txd1 output pin irq3 input pin when the irq3e bit in ier is set to 1, this pin is used as the irq3 input pin.
232 pin selection method and pin functions p83/ lpcpd the pin function is switched as shown below according to bit p83ddr. p83ddr 0 1 pin function p83 input pin p83 output pin lpcpd input pin when at least one of bits lpc3e to lpc1e is set to 1 in hicr0, this pin is used as the lpcpd input pin. the lpcpd input pin can only be used in mode 2 or 3 (expe = 0). p82/hifsd/ clkrun the pin function is switched as shown below according to the combination of bits hi12e and sde in syscr2, bits lpc3e to lpc1e in hicr0, and bit p82ddr. note: * when at least one of bits lpc3e to lpc1e is set to 1, bits hi12e and p82ddr should be cleared to 0. lpc3e to lpc1e all 0 not all 0 hi12e 0 1 * sde 0 1 p82ddr 0 1 0 1 * pin function p82 input pin p82 output pin p82 input pin p82 output pin hifsd input pin clkrun i/o pin the hifsd input pin and clkrun i/o pin can only be used in mode 2 or 3 (expe = 0).
233 pin selection method and pin functions p81/ga20/ cs2 the pin function is switched as shown below according to the combination of bit hi12e in syscr2, bit cs2e in syscr, bit fga20e in hicr, bit fga20e in hicr0, and bit p81ddr. note: * when bit fga20e is set to 1 in hicr0, bits hi12e and p81ddr should be cleared to 0. fga20e (lpc) 01 hi12e 0 1 * fga20e (xbs) ? 1 cs2e 0 1 p81ddr 0 1 0 1 0 1 pin function p81 input pin p81 output pin p81 input pin p81 output pin cs2 input pin p81 input pin ga20 output pin ga20 output pin ga20 input pin the ga20 output pin and cs2 input pin can only be used in mode 2 or 3 (expe = 0). p80/ha0/ pme the pin function is switched as shown below according to the combination of bit hi12e in syscr2, bit pmee in hicr0, and bit p80ddr. note: * when bit pmee is set to 1 in hicr0, bits hi12e and p80ddr should be cleared to 0. pmee 0 1 hi12e 0 1 * p80ddr 0 1 * pin function p80 input pin p80 output pin ha0 input pin pme output pin pme input pin the ha0 input pin can only be used in mode 2 or 3 (expe = 0).
234 8.10 port 9 8.10.1 overview port 9 is an 8-bit i/o port. port 9 pins also function as external interrupt input pins ( irq0 to irq2 ), the a/d converter external trigger input pin ( adtrg ), host interface (xbs) input pins ( ecs2 , cs1 , iow , ior ), the iic0 i/o pin (sda0), the subclock input pin (excl), bus control signal i/o pins ( as / ios , rd , hwr , lwr , wait ), and the system clock (?) output pin. p97 is an nmos push-pull output. sda0 is an nmos open-drain output, and has direct bus drive capability. figure 8.17 shows the port 9 pin configuration. p97/ wait /sda0 p96/?/excl p95/ as / ios / cs1 p94/ hwr / iow p93/ rd / ior p92/ irq0 p91/ irq1 p90/ lwr / irq2 / adtrg / ecs2 port 9 port 9 pins wait (input)/p97 (i/o)/sda0 (i/o) ? (output)/p96 (input)/excl (input) as (output)/ ios (output) hwr (output) rd (output) p92 (i/o)/ irq0 (input) p91 (i/o)/ irq1 (input) p90 (i/o)/ lwr (output)/ irq2 (input)/ adtrg (input) pin functions in modes 1, 2 and 3 (expe = 1) p97 (i/o)/sda0 (i/o) p96 (input)/? (output)/excl (input) p95 (i/o)/ cs1 (input) p94 (i/o)/ iow (input) p93 (i/o)/ ior (input) p92 (i/o)/ irq0 (input) p91 (i/o)/ irq1 (input) p90 (i/o)/ irq2 (input)/ adtrg (input)/ ecs2 (input) pin functions in modes 2 and 3 (expe = 0) figure 8.17 port 9 pin functions
235 8.10.2 register configuration table 8.18 summarizes the port 9 registers. table 8.18 port 9 registers name abbreviation r/w initial value address * 1 port 9 data direction register p9ddr w h'40/h'00 * 2 h'ffc0 port 9 data register p9dr r/w h'00 h'ffc1 notes: 1. lower 16 bits of the address. 2. initial value depends on the mode. port 9 data direction register (p9ddr) bit 76543210 p97ddr p96ddr p95ddr p94ddr p93ddr p92ddr p91ddr p90ddr mode 1 initial value 01000000 read/write wwwwwwww modes 2 and 3 initial value 00000000 read/write wwwwwwww p9ddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port 9. p9ddr cannot be read; if it is, an undefined value will be returned. p9ddr is initialized to h'40 (mode 1) or h'00 (modes 2 and 3) by a reset and in hardware standby mode. it retains its prior state in software standby mode. ? modes 1, 2, and 3 (expe = 1) pin p97 functions as a bus control input ( wait ), the iic0 i/o pin (sda0), or an i/o port, according to the wait mode setting. when p97 functions as an i/o port, it becomes an output port when p97ddr is set to 1, and an input port when p97ddr is cleared to 0. pin p96 functions as the ? output pin when p96ddr is set to 1, and as the subclock input (excl) or an input port when p96ddr is cleared to 0. pins p95 to p93 automatically become bus control outputs ( as / ios , hwr , rd ), regardless of the input/output direction indicated by p95ddr to p93ddr. pins p92 and p91 become output ports when p92ddr and p91ddr are set to 1, and input ports when p92ddr and p91ddr are cleared to 0.
236 when the abw bit in wscr is cleared to 0, pin p90 becomes a bus control output ( lwr ), regardless of the input/output direction indicated by p90ddr. when the abw bit is 1, pin p90 becomes an output port if p90ddr is set to 1, and an input port if p90ddr is cleared to 0. modes 2 and 3 (expe = 0) when the corresponding p9ddr bits are set to 1, pin p96 functions as the ? output pin and pins p97 and p95 to p90 become output ports. when p9ddr bits are cleared to 0, the corresponding pins become input ports. port 9 data register (p9dr) bit 76543210 p97dr p96dr p95dr p94dr p93dr p92dr p91dr p90dr initial value 0 * 000000 read/write r/w r r/w r/w r/w r/w r/w r/w note: * determined by the state of pin p96. p9dr is an 8-bit readable/writable register that stores output data for the port 9 pins (p97 to p90). with the exception of p96, if a port 9 read is performed while p9ddr bits are set to 1, the p9dr values are read directly, regardless of the actual pin states. if a port 9 read is performed while p9ddr bits are cleared to 0, the pin states are read. p9dr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. 8.10.3 pin functions port 9 pins also function as external interrupt input pins ( irq0 to irq2 ), the a/d converter trigger input pin ( adtrg ), host interface (xbs) input pins ( ecs2 , cs1 , iow , ior ), the iic0 i/o pin (sda0), the subclock input pin (excl), bus control signal i/o pins ( as / ios , rd , hwr , lwr , wait ), and the system clock (?) output pin. the pin functions differ between the mode 1, 2, and 3 (expe = 1) expanded modes and the mode 2 and 3 (expe = 0) single-chip modes. the port 9 pin functions are shown in table 8.19.
237 table 8.19 port 9 pin functions pin selection method and pin functions p97/ wait /sda0 the pin function is switched as shown below according to the combination of operating mode, bit wms1 in wscr, bit ice in iccr of iic0, and bit p97ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) wms1 0 1 ice 0 1 0 1 p97ddr 0 1 0 1 pin function p97 input pin p97 output pin sda0 i/o pin wait input pin p97 input pin p97 output pin sda0 i/o pin when this pin is set as the p97 output pin, it is an nmos push-pull output. sda0 is an nmos open-drain output, and has direct bus drive capability. p96/?excl the pin function is switched as shown below according to the combination of bit excle in lpwrcr and bit p96ddr. p96ddr 0 1 excle 0 1 0 pin function p96 input pin excl input pin ?output pin when this pin is used as the excl input pin, p96ddr should be cleared to 0. p95/ as / ios / cs1 the pin function is switched as shown below according to the combination of operating mode, bit iose in syscr, bit hi12e in syscr2, and bit p95ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p95ddr 0 1 iose 0 1 pin function as output pin ios output pin p95 input pin p95 output pin cs1 input pin
238 pin selection method and pin functions p94/ hwr / iow the pin function is switched as shown below according to the combination of operating mode, bit hi12e in syscr2, and bit p94ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p94ddr 0 1 pin function hwr output pin p94 input pin p94 output pin iow input pin p93/ rd / ior the pin function is switched as shown below according to the combination of operating mode, bit hi12e in syscr2, and bit p93ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e 0 1 p93ddr 0 1 pin function rd output pin p93 input pin p93 output pin ior input pin p92/ irq0 p92ddr 0 1 pin function p92 input pin p92 output pin irq0 input pin when bit irq0e in ier is set to 1, this pin is used as the irq0 input pin. p91/ irq1 p91ddr 0 1 pin function p91 input pin p91 output pin irq1 input pin when bit irq1e in ier is set to 1, this pin is used as the irq1 input pin.
239 pin selection method and pin functions p90/ lwr / irq2 / adtrg / ecs2 the pin function is switched as shown below according to the combination of operating mode, bit abw in wscr, bits hi12e and cs2e in syscr2, bit fga20e in hicr, and bit p90ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 hi12e any one 0 1 fga20e 1 cs2e 1 p90ddr 0101 pin function lwr output pin p90 input pin p90 output pin p90 input pin p90 output pin ecs2 input pin irq2 input pin, adtrg input pin when the irq2e bit in ier is set to 1 in mode 1, 2, or 3 (expe = 1) with the abw bit in wscr set to 1, or in mode 2 and 3 (expe = 0), this pin is used as the irq2 input pin. when trgs1 and trgs0 in adcr of the a/d converter are both set to 1, this pin is used as the adtrg input pin.
240 8.11 port a 8.11.1 overview port a is an 8-bit i/o port. port a pins also function as keyboard buffer controller i/o pins (ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd), key-sense interrupt input pins ( kin15 to kin8 ), expansion a/d converter input pins (cin15 to cin8), and address output pins (a23 to a16). port a pin functions are the same in all operating modes. figure 8.18 shows the port a pin configuration. pa7/a23/ kin15 /cin15/ps2cd pa6/a22/ kin14 /cin14/ps2cc pa5/a21/ kin13 /cin13/ps2bd pa4/a20/ kin12 /cin12/ps2bc pa3/a19/ kin11 /cin11/ps2ad pa2/a18/ kin10 /cin10/ps2ac pa1/a17/ kin9 /cin9 pa0/a16/ kin8 /cin8 port a port a pins pa7 (i/o)/ kin15 (input)/cin15 (input)/ps2cd (i/o) pa6 (i/o)/ kin14 (input)/cin14 (input)/ps2cc (i/o) pa5 (i/o)/ kin13 (input)/cin13 (input)/ps2bd (i/o) pa4 (i/o)/ kin12 (input)/cin12 (input)/ps2bc (i/o) pa3 (i/o)/ kin11 (input)/cin11 (input)/ps2ad (i/o) pa2 (i/o)/ kin10 (input)/cin10 (input)/ps2ac (i/o) pa1 (i/o)/ kin9 (input)/cin9 (input) pa0 (i/o)/ kin8 (input)/cin8 (input) pin functions in modes 1 and 2 (expe = 0) and mode 3 pa7 (i/o)/a23 (output)/ kin15 (input)/cin15 (input)/ps2cd (i/o) pa6 (i/o)/a22 (output)/ kin14 (input)/cin14 (input)/ps2cc (i/o) pa5 (i/o)/a21 (output)/ kin13 (input)/cin13 (input)/ps2bd (i/o) pa4 (i/o)/a20 (output)/ kin12 (input)/cin12 (input)/ps2bc (i/o) pa3 (i/o)/a19 (output)/ kin11 (input)/cin11 (input)/ps2ad (i/o) pa2 (i/o)/a18 (output)/ kin10 (input)/cin10 (input)/ps2ac (i/o) pa1 (i/o)/a17 (output)/ kin9 (input)/cin9 (input) pa0 (i/o)/a16 (output)/ kin8 (input)/cin8 (input) pin functions in mode 2 (expe = 1) figure 8.18 port a pin functions
241 8.11.2 register configuration table 8.20 summarizes the port a registers. table 8.20 port a registers name abbreviation r/w initial value address * 1 port a data direction register paddr w h'00 h'ffab * 2 port a output data register paodr r/w h'00 h'ffaa port a input data register papin r undefined h'ffab * 2 notes: 1. lower 16 bits of the address. 2. paddr and papin have the same address. port a data direction register (paddr) bit 76543210 pa7ddr pa6ddr pa5ddr pa4ddr pa3ddr pa2ddr pa1ddr pa0ddr initial value 0 0 0 0 0 0 0 0 read/write w w w w w w w w paddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port a. setting a paddr bit to 1 makes the corresponding port a pin an output pin, while clearing the bit to 0 makes the pin an input pin. paddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port a output data register (paodr) bit 76543210 pa7odr pa6odr pa5odr pa4odr pa3odr pa2odr pa1odr pa0odr initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w paodr is an 8-bit readable/writable register that stores output data for the port a pins (pa7 to pa0). paodr can always be read or written to, regardless of the contents of paddr. paodr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode.
242 port a input data register (papin) bit 76543210 pa7pin pa6pin pa5pin pa4pin pa3pin pa2pin pa1pin pa0pin initial value * * * * * * * * read/write r r r r r r r r note: * determined by the state of pins pa7 to pa0. reading papin always returns the pin states. 8.11.3 pin functions port a pins also function as keyboard buffer controller i/o pins (ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd), key-sense interrupt input pins ( kin15 to kin8 ), expansion a/d converter input pins (cin15 to cin8), and address output pins (a23 to a16). the port a pin functions are shown in table 8.21. table 8.21 port a pin functions pin selection method and pin functions pa7/a23/ps2cd/ kin15 /cin15 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr2h of the keyboard buffer controller, the iose bit in syscr, and bit pa7ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa7ddr 0 1 0 1 iose 0 1 pin function pa7 input pin pa7 output pin ps2cd output pin pa7 input pin a23 output pin pa7 output pin ps2cd output pin kin15 input pin, cin15 input pin, ps2cd input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2cd, kin15 , or cin15 input pin.
243 pin selection method and pin functions pa6/a22/ps2cc/ kin14 /cin14 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr2h of the keyboard buffer controller, the iose bit in syscr, and bit pa6ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa6ddr 0 1 0 1 iose 0 1 pin function pa6 input pin pa6 output pin ps2cc output pin pa6 input pin a22 output pin pa6 output pin ps2cc output pin kin14 input pin, cin14 input pin, ps2cc input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2cc, kin14 , or cin14 input pin. pa5/a21/ps2bd/ kin13 /cin13 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr1h of the keyboard buffer controller, the iose bit in syscr, and bit pa5ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa5ddr 0 1 0 1 iose 0 1 pin function pa5 input pin pa5 output pin ps2bd output pin pa5 input pin a21 output pin pa5 output pin ps2bd output pin kin13 input pin, cin13 input pin, ps2bd input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2bd, kin13 , or cin13 input pin.
244 pin selection method and pin functions pa4/a20/ps2bc/ kin12 /cin12 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr1h of the keyboard buffer controller, the iose bit in syscr, and bit pa4ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa4ddr 0 1 0 1 iose 0 1 pin function pa4 input pin pa4 output pin ps2bc output pin pa4 input pin a20 output pin pa4 output pin ps2bc output pin kin12 input pin, cin12 input pin, ps2bc input pin when the iics bit in stcr is set to 1, this pin functions as a bus buffer. this pin can always be used as the ps2bc, kin12 , or cin12 input pin. pa3/a19/ps2ad/ kin11 /cin11 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr0h of the keyboard buffer controller, the iose bit in syscr, and bit pa3ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa3ddr 0 1 0 1 iose 0 1 pin function pa3 input pin pa3 output pin ps2ad output pin pa3 input pin a19 output pin pa3 output pin ps2ad output pin kin11 input pin, cin11 input pin, ps2ad input pin this pin can always be used as the ps2ad, kin11 , or cin11 input pin.
245 pin selection method and pin functions pa2/a18/ps2ac/ kin10 /cin10 the pin function is switched as shown below according to the combination of operating mode, the kbioe bit in kbcr0h of the keyboard buffer controller, the iose bit in syscr, and bit pa2ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) kbioe 0 1 0 1 pa2ddr 0 1 0 1 iose 0 1 pin function pa2 input pin pa2 output pin ps2ac output pin pa2 input pin a18 output pin pa2 output pin ps2ac output pin kin10 input pin, cin10 input pin, ps2ac input pin this pin can always be used as the ps2ac, kin10 , or cin10 input pin. pa1/a17/ kin9 / cin9 the pin function is switched as shown below according to the combination of operating mode, the iose bit in syscr and bit pa1ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) pa1ddr 0 1 0 1 iose 0 1 pin function pa1 input pin pa1 output pin pa1 input pin a17 output pin pa1 output pin kin9 input pin, cin9 input pin this pin can always be used as the kin9 or cin9 input pin. pa0/a16/ kin8 / cin8 the pin function is switched as shown below according to the combination of operationg mode, the iose bit in syscr and bit pa0ddr. operating mode modes 1, 2 (expe = 0), 3 mode 2 (expe = 1) pa0ddr 0 1 0 1 iose 0 1 pin function pa0 input pin pa0 output pin pa0 input pin a16 output pin pa0 output pin kin8 input pin, cin8 input pin this pin can always be used as the kin8 or cin8 input pin.
246 8.11.4 mos input pull-up function port a has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in any operating mode, and can be specified as on or off on a bit-by-bit basis. when a paddr bit is cleared to 0, setting the corresponding paodr bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up for pins pa7 to pa4 is always off when iics is set to 1. when the keyboard buffer control pin function is selected for pins pa7 to pa2, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.22 summarizes the mos input pull-up states. table 8.22 mos input pull-up states (port a) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when paddr = 0 and paodr = 1; otherwise off.
247 8.12 port b 8.12.1 overview port b is an 8-bit i/o port. port b pins also have host interface (xbs) input/output pins ( cs3 , cs4 , hirq3, hirq4), host interface (lpc) input/output pins (lsci, lsmi ), wakeup event interrupt input pins ( wue7 to wue0 ), and a data bus input/output function (as d7 to d0). the pin functions depend on the operating mode. figure 8.19 shows the port b pin configuration. pb7/d7/ wue7 pb6/d6/ wue6 pb5/d5/ wue5 pb4/d4/ wue4 pb3/d3/ wue3 / cs4 pb2/d2/ wue2 / cs3 pb1/d1/ wue1 /hirq4/lsci pb0/d0/ wue0 /hirq3/ lsmi port b port b pins d7 (i/o) d6 (i/o) d5 (i/o) d4 (i/o) d3 (i/o) d2 (i/o) d1 (i/o) d0 (i/o) modes 1, 2, and 3 (expe = 1) when abw = 0 pb7 (i/o)/ wue7 (input) pb6 (i/o)/ wue6 (input) pb5 (i/o)/ wue5 (input) pb4 (i/o)/ wue4 (input) pb3 (i/o)/ wue3 (input)/ cs4 (input) pb2 (i/o)/ wue2 (input)/ cs3 (input) pb1 (i/o)/ wue1 (input)/hirq4 (output)/lsci (i/o) pb0 ( i/o ) / wue0 ( input ) /hirq3 ( output ) / lsmi ( i/o ) modes 1, 2, and 3 (expe = 1) when abw = 1, and modes 1, 2, and 3 (expe = 0) figure 8.19 port b pin functions
248 8.12.2 register configuration table 8.23 summarizes the port b registers. table 8.23 port b registers name abbreviation r/w initial value address * 1 port b data direction register pbddr w h'00 h'ffbe * 2 port b output data register pbodr r/w h'00 h'ffbc port b input data register pbpin r undefined h'ffbd * 3 notes: 1. lower 16 bits of the address. 2. pbddr has the same address as p7pin. 3. pbpin has the same address as p8ddr. port b data direction register (pbddr) bit 76543210 pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr initial value 0 0 0 0 0 0 0 0 read/write w w w w w w w w pbddr is an 8-bit write-only register, the individual bits of which specify input or output for the pins of port b. pbddr has the same address as p7pin, and if read, the port 7 pin states will be returned. setting a pbddr bit to 1 makes the corresponding port b pin an output pin, while clearing the bit to 0 makes the pin an input pin. pbddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. ? modes 1, 2, and 3 (expe = 1) when the abw bit in wscr is cleared to 0, port b pins automatically become data i/o pins (d7 to d0), regardless of the input/output direction indicated by pbddr. when the abw bit is 1, a port b pin becomes an output port if the corresponding pbddr bit is set to 1, and an input port if the bit is cleared to 0. data i/o pins go to the high-impedance state after a reset, and in hardware standby mode or software standby mode. ? modes 2 and 3 (expe = 0) a port b pin becomes an output port if the corresponding pbddr bit is set to 1, and an input port if the bit is cleared to 0.
249 port b output data register (pbodr) bit 76543210 pb7odr pb6odr pb5odr pb4odr pb3odr pb2odr pb1odr pb0odr initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w pbodr is an 8-bit readable/writable register that stores output data for the port b pins (pb7 to pb0). pbodr can always be read or written to, regardless of the contents of pbddr. pbodr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port b input data register (pbpin) bit 76543210 pb7pin pb6pin pb5pin pb4pin pb3pin pb2pin pb1pin pb0pin initial value * * * * * * * * read/write r r r r r r r r note: * determined by the state of pins pb7 to pb0. reading pbpin always returns the pin states. pbpin has the same address as p8ddr. if a write is performed, data will be written to p8ddr and the port 8 settings will change.
250 8.12.3 pin functions port b pins also function as host interface (xbs) i/o pins ( cs3 , cs4 , hirq3, hirq4), host interface (lpc) i/o pins (lsci, lsmi ), wakeup event interrupt input pins ( wue7 to wue0 ), and data bus i/o pins (d7 to d0). the port b pin functions are shown in table 8.24. table 8.24 port b pin functions pin selection method and pin functions pb7/d7/ wue7 the pin function is switched as shown below according to the combination of the operating mode, bit pb7ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb7ddr 0101 pin function d7 i/o pin pb7 input pin pb7 output pin pb7 input pin pb7 output pin wue7 input pin except when used as a data bus pin, this pin can always be used as the wue7 input pin. pb6/d6/ wue6 the pin function is switched as shown below according to the combination of the operating mode, bit pb6ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb6ddr 0101 pin function d6 i/o pin pb6 input pin pb6 output pin pb6 input pin pb6 output pin wue6 input pin except when used as a data bus pin, this pin can always be used as the wue6 input pin.
251 pin selection method and pin functions pb5/d5/ wue5 the pin function is switched as shown below according to the combination of the operating mode, bit pb5ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb5ddr 0101 pin function d5 i/o pin pb5 input pin pb5 output pin pb5 input pin pb5 output pin wue5 input pin except when used as a data bus pin, this pin can always be used as the wue5 input pin. pb4/d4/ wue4 the pin function is switched as shown below according to the combination of the operating mode, bit pb4ddr, and bit abw in wscr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) abw 0 1 pb4ddr 0101 pin function d4 i/o pin pb4 input pin pb4 output pin pb4 input pin pb4 output pin wue4 input pin except when used as a data bus pin, this pin can always be used as the wue4 input pin.
252 pin selection method and pin functions pb3/d3/ wue3 / cs4 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs4e in syscr2, bit abw in wscr, and bit pb3ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs4e 1 abw 0 1 pb3ddr 0 1 0 1 pin function d3 i/o pin pb3 input pin pb3 output pin pb3 input pin pb3 output pin cs4 input pin wue3 input pin except when used as a data bus pin, this pin can always be used as the wue3 input pin. the cs4 input pin can only be used in mode 2 or 3 (expe = 0). pb2/d2/ wue2 / cs3 the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs3e in syscr2, bit abw in wscr, and bit pb2ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) hi12e either cleared to 0 1 cs3e 1 abw 0 1 pb2ddr 0 1 0 1 pin function d2 i/o pin pb2 input pin pb2 output pin pb2 input pin pb2 output pin cs3 input pin wue2 input pin except when used as a data bus pin, this pin can always be used as the wue2 input pin. the cs3 input pin can only be used in mode 2 or 3 (expe = 0).
253 pin selection method and pin functions pb1/d1/ wue1 / hirq4/lsci the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs4e in syscr2, bit abw in wscr, and bit pb1ddr. note: * when bit lscie is set to 1 in hicr0, bits hi12e and pb1ddr should be cleared to 0. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) lscie 0 1 hi12e either cleared to 0 1 * cs4e 1 abw 0 1 pb1ddr 0101 1 * pin function d1 i/o pin pb1 input pin pb1 output pin pb1 input pin pb1 output pin hirq4 output pin lsci output pin lsci input pin wue1 input pin except when used as a data bus pin, this pin can always be used as the wue1 input pin. the hirq4 output pin and lsci i/o pin can only be used in mode 2 or 3 (expe = 0).
254 pin selection method and pin functions pb0/d0/ wue0 / hirq3/ lsmi the pin function is switched as shown below according to the combination of the operating mode, bits hi12e and cs3e in syscr2, bit abw in wscr, and bit pb0ddr. operating mode modes 1, 2, 3 (expe = 1) modes 2, 3 (expe = 0) lsmie 0 1 hi12e either cleared to 0 1 * cs3e 1 * abw 0 1 pb0ddr 0101 1 * pin function d0 i/o pin pb0 input pin pb0 output pin pb0 input pin pb0 output pin hirq3 output pin lsmi output pin lsmi input pin wue0 input pin except when used as a data bus pin, this pin can always be used as the wue0 input pin. the hirq3 output pin and lsmi i/o pin can only be used in mode 2 or 3 (expe = 0).
255 8.12.4 mos input pull-up function port b has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be used in modes 1, 2, and 3 (expe = 1) with the abw bit in wscr set to 1, and in modes 2 and 3 (expe = 0), and can be specified as on or off on a bit-by-bit basis. when a pbddr bit is cleared to 0, setting the corresponding pbodr bit to 1 turns on the mos input pull-up for that pin. when a pin is designated as an on-chip supporting module output pin, the mos input pull-up is always off. the mos input pull-up function is in the off state after a reset and in hardware standby mode. the prior state is retained in software standby mode. table 8.25 summarizes the mos input pull-up states. table 8.25 mos input pull-up states (port b) mode reset hardware standby mode software standby mode in other operations 1, 2, 3 (expe = 1) with abw in wscr = 0 off off off off 1, 2, 3 (expe = 1) with abw in wscr = 1, and 2, 3 (expe = 0) off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when pbddr = 0 and pbodr = 1; otherwise off. 8.13 additional overview for h8s/2169 the h8s/2169 has fifteen i/o ports (ports 1 to 6, 8, 9, a, b, c, d, e, f, and g), and one input-only port (port 7). table 8.26 is a summary of the additional port functions. as the functions of ports 1 to 9, a, and b are the same on the h8s/2149, table 8.1 provides a summary. each extra port includes a data direction register (ddr) that controls input/output, and data registers (odr) for storing output data. ports c, d, e, f, and g have a built-in mos input pull-up function. on ports c, d, e, f, and g, whether the mos input pull-up is on or off is controlled by the corresponding ddr and odr. ports c, d, e, f, and g can drive a single-ttl load and 30-pf-capacitive load. all i/o port pins are capable of driving a darlington transistor when they are in output mode.
256 input and output on ports e, f, and g are powered by vccb, which is independent of the v cc power supply. so, when the vccb voltage is 5 v, the pins on ports e, f, and g can be 5-v tolerant. table 8.26 h8s/2169 additional port functions expanded modes single-chip mode port description pins mode 1 mode 2, mode 3 (expe = 1) mode 2, mode 3 (expe = 0) port c 8-bit i/o port built-in mos input pull-ups pc7 to pc0 i/o port i/o port i/o port port d 8-bit i/o port built-in mos input pull-ups pd7 to pd0 i/o port i/o port i/o port port e 8-bit i/o port built-in mos input pull-ups pe7 to pe0 i/o port i/o port i/o port port f 8-bit i/o port built-in mos input pull-ups pf7 to pf0 i/o port i/o port i/o port port g 8-bit i/o port built-in mos input pull-ups pg7 to pg0 i/o port i/o port i/o port 8.14 ports c, d 8.14.1 overview port c and port d are two sets of 8-bit i/o ports. the pin functions are the same in all operating modes. figure 8.20 shows the pin configuration for ports c and d.
257 pc7 (i/o) pc6 (i/o) pc5 (i/o) pc4 (i/o) pc3 (i/o) pc2 (i/o) pc1 (i/o) pc0 (i/o) port c port c pins pd7 (i/o) pd6 (i/o) pd5 (i/o) pd4 (i/o) pd3 (i/o) pd2 (i/o) pd1 (i/o) pd0 (i/o) port d port d pins figure 8.20 pin functions for ports c and d 8.14.2 register configuration table 8.27 is a summary of the port c and port d registers. table 8.27 port c and port d registers name abbreviation r/w initial value address* 1 port c data direction register pcddr w h'00 h'fe4e* 2 port c output data register pcodr r/w h'00 h'fe4c port c input data register pcpin r undefined h'fe4e* 2 port c nch-od control register pcnocr r/w h'00 h'fe1c port d data direction register pdddr w h'00 h'fe4f* 3 port d output data register pdodr r/w h'00 h'fe4d port d input data register pdpin r undefined h'fe4f* 3 port d nch-od control register pdnocr r/w h'00 h'fe1d notes: 1. lower 16 bits of the address. 2. pcddr has the same address as pcpin. 3. pdddr has the same address as pdpin.
258 port c and port d data direction registers (pcddr, pdddr) bit 76543210 pc7ddr pc6ddr pc5ddr pc4ddr pc3ddr pc2ddr pc1ddr pc0ddr initial value 0 0 000000 read/write w w wwwwww bit 76543210 pd7ddr pd6ddr pd5ddr pd4ddr pd3ddr pd2ddr pd1ddr pd0ddr initial value 0 0 000000 read/write w w wwwwww pcddr and pdddr are 8-bit write-only registers, the individual bits of which select input or output for the pins of port c and port d. pcddr and pdddr are at the same addresses as pcpin and pdpin, respectively, and if read, will return the port c and port d pin states. setting a pcddr or pdddr bit to 1 makes the corresponding pin on port c or port d an output pin. clearing the bit to 0 makes the pin an input pin. pcddr and pdddr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode. port c and port d output data registers (pcodr, pdodr) bit 76543210 pc7odr pc6odr pc5odr pc4odr pc3odr pc2odr pc1odr pc0odr initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w bit 76543210 pd7odr pd6odr pd5odr pd4odr pd3odr pd2odr pd1odr pd0odr initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w pcodr and pdodr are 8-bit read/write registers that store output data for the pins on ports c and d (pc7 to pc0 and pd7 to pd0). pcodr and pdodr can always be read from or written to, regardless of the pcddr and pdddr settings. pcodr and pdodr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode.
259 port c and port d input data registers (pcpin, pdpin) bit 76543210 pc7pin pc6pin pc5pin pc4pin pc3pin pc2pin pc1pin pc0pin initial value * * * * * * * * read/write r r rrrrrr note: * determined by the state of pins pc7 to pc0. bit 76543210 pd7pin pd6pin pd5pin pd4pin pd3pin pd2pin pd1pin pd0pin initial value * * * * * * * * read/write r r rrrrrr note: * determined by the state of pins pd7 to pd0. reading pcpin and pdpin always returns the pin states. pcpin and pdpin are at the same addresses as pcddr and pdddr, respectively. writing is to pcddr or pdddr and the port c or port d settings will change unless the given byte represents the current setting. port c and port d nch-od control register (pcnocr, pdnocr) bit 76543210 pc7noc pc6noc pc5noc pc4noc pc3noc pc2noc pc1noc pc0noc initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w bit 76543210 pd7noc pd6noc pd5noc pd4noc pd3noc pd2noc pd1noc pd0noc initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w
260 pcnocr and pdnocr are 8-bit read/write registers, the individual bits of which specify the output driver type for pins on ports c and d which are configured as outputs. setting a pcnocr or pdnocr bit to 1 disables the p-channel driver for the corresponding pin on port c or port d. clearing the bit to 0 enables the p-channel driver for the pin. although the p- channel drivers are always connected, the output driver type will be cmos when the bit is cleared to 0 and n-channel open-drain when it is set to 1. pcnocr and pdnocr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode. ddr 0 1 nocr 0 1 odr 0 1 0 1 0 1 n-ch. driver off on off on off p-ch. driver off off on off mos input pul-up off on off 8.14.3 pin functions the port c and port d pins have only one special function. 8.14.4 mos input pull-up function port c and port d have a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be switched on or off on a bit-by-bit basis. when a pcddr or pdddr bit is cleared to 0, setting the corresponding pcodr or pdodr bit to 1 will turn on the mos input pull-up for that pin. the mos input pull-up function is off after a reset and in hardware standby mode. the prior state is retained when in software standby mode. table 8.28 is a summary of the mos input pull-up states.
261 table 8.28 mos input pull-up states (port c and port d) mode reset hardware standby mode software standby mode other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when pcddr = 0 and pcodr = 1 (pdddr = 0 and pdodr = 1); otherwise off. 8.15 ports e, f 8.15.1 overview port e and port f are two sets of 8-bit i/o ports. the pins of ports e and f have the same functions in all operating modes. figure 8.21 shows the pin configuration of port e and port f. pe7 (i/o) pe6 (i/o) pe5 (i/o) pe4 (i/o) pe3 (i/o) pe2 (i/o) pe1 (i/o) pe0 (i/o) port e port e pins pf7 (i/o) pf6 (i/o) pf5 (i/o) pf4 (i/o) pf3 (i/o) pf2 (i/o) pf1 (i/o) pf0 (i/o) port f port f pins figure 8.21 pin functions for ports e and f
262 8.15.2 register configuration table 8.29 is a summary of the port e and port f registers. table 8.29 port e and port f registers name abbreviation r/w initial value address * 1 port e data direction register peddr w h'00 h'fe4a * 2 port e output data register peodr r/w h'00 h'fe48 port e input data register pepin r undefined h'fe4a * 2 port e nch-od control register penocr r/w h'00 h'fe18 port f data direction register pfddr w h'00 h'fe4b * 3 port f output data register pfodr r/w h'00 h'fe49 port f input data register pfpin r undefined h'fe4b * 3 port f nch-od control register pfnocr r/w h'00 h'fe19 notes: 1. lower 16 bits of the address. 2. peddr has the same address as pepin. 3. pfddr has the same address as pfpin. port e and port f data direction registers (peddr, pfddr) bit 76543210 pe7ddr pe6ddr pe5ddr pe4ddr pe3ddr pe2ddr pe1ddr pe0ddr initial value 0 0 000000 read/write w w wwwwww bit 76543210 pf7ddr pf6ddr pf5ddr pf4ddr pf3ddr pf2ddr pf1ddr pf0ddr initial value 0 0 000000 read/write w w wwwwww peddr and pfddr are 8-bit write-only registers, the individual bits of which select input or output for the pins of port e and port f. peddr and pfddr are at the same addresses as pepin and pfpin, respectively, and if read, will return the port e and port f pin states. setting a peddr or pfddr bit to 1 makes the corresponding pin on port e or port f an output pin, while clearing the bit to 0 makes the pin an input pin. peddr and pfddr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode.
263 port e and port f output data registers (peodr, pfodr) bit 76543210 pe7odr pe6odr pe5odr pe4odr pe3odr pe2odr pe1odr pe0odr initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w bit 76543210 pf7odr pf6odr pf5odr pf4odr pf3odr pf2odr pf1odr pf0odr initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w peodr and pfodr are 8-bit read/write registers that store output data for the pins on ports e and f (pe7 to pe0 and pf7 to pf0). peodr and pfodr can always be read from or written to, regardless of the peddr and pfddr settings. peodr and pfodr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode. port e and port f input data registers (pepin, pfpin) bit 76543210 pe7pin pe6pin pe5pin pe4pin pe3pin pe2pin pe1pin pe0pin initial value * * * * * * * * read/write r r rrrrrr note: * determined by the state of pins pe7 to pe0. bit 76543210 pf7pin pf6pin pf5pin pf4pin pf3pin pf2pin pf1pin pf0pin initial value * * * * * * * * read/write r r rrrrrr note: * determined by the state of pins pf7 to pf0. reading pepin and pfpin always returns the pin states. pepin and pfpin are at the same addresses as peddr and pfddr, respectively. writing is to peddr or pfddr and the port e or port f settings will change unless the given byte represents the current setting.
264 port e and port f nch-od control registers (penocr, pfnocr) bit 76543210 pe7noc pe6noc pe5noc pe4noc pe3noc pe2noc pe1noc pe0noc initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w bit 76543210 pf7noc pf6noc pf5noc pf4noc pf3noc pf2noc pf1noc pf0noc initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w penocr and pfnocr are 8-bit read/write registers, the individual bits of which specify the output driver type for pins on ports e and f which are configured as outputs. setting a penocr or pfnocr bit to 1 disables the p-channel driver for the corresponding pin on port e or port f. clearing the bit to 0 enables the p-channel driver for the pin. although the p- channel drivers are always connected, the output driver type will be cmos when the bit is cleared to 0 and n-channel open-drain when it is set to 1. penocr and pfnocr are initialized to h'00 by a reset and in hardware standby mode. they retain their prior states in software standby mode. ddr 0 1 nocr 0 1 odr 0 1 0 1 0 1 n-ch. driver off on off on off p-ch. driver off off on off mos input pul-up off on off
265 8.15.3 pin functions the port e and port f pins have only one special function. 8.15.4 mos input pull-up function port e and port f have a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be switched as on or off on a bit-by-bit basis. when a peddr or pfddr bit is cleared to 0, setting the corresponding peodr or pfodr bit to 1 will turn on the mos input pull-up for that pin. the mos input pull-up function is off after a reset and in hardware standby mode. the prior state is retained when in software standby mode. table 8.30 is a summary of the mos input pull-up states. table 8.30 mos input pull-up states (port e and port f) mode reset hardware standby mode software standby mode other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when peddr = 0 and peodr = 1 (pfddr = 0 and pfodr = 1); otherwise off.
266 8.16 port g 8.16.1 overview port g is an 8-bit i/o port. port g pin functions are the same in all operating modes. figure 8.22 shows the pin configuration of port g. pg7 (i/o) pg6 (i/o) pg5 (i/o) pg4 (i/o) pg3 (i/o) pg2 (i/o) pg1 (i/o) pg0 (i/o) port g port c pins figure 8.22 pin functions for port g 8.16.2 register configuration table 8.31 is a summary of the port g registers. table 8.31 port g registers name abbreviation r/w initial value address * 1 port g data direction register pgddr w h'00 h'fe47 * 2 port g output data register pgodr r/w h'00 h'fe46 port g input data register pgpin r undefined h'fe47 * 3 port g nch-od control register pgnocr r/w h'00 h'fe16 notes: 1. lower 16 bits of the address. 2. pgddr has the same address as pgpin.
267 port g data direction register (pgddr) bit 76543210 pg7ddr pg6ddr pg5ddr pg4ddr pg3ddr pg2ddr pg1ddr pg0ddr initial value 0 0 000000 read/write w w wwwwww pgddr is an 8-bit write-only register, the individual bits of which select input or output for the pins of port g. pgddr is at the same address as pgpin, and if read, will return the port g pin states. setting a pgddr bit to 1 makes the corresponding pins on port g an output pin, while clearing the bit to 0 makes the pin an input pin. pgddr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port g output data register (pgodr) bit 76543210 pg7odr pg6odr pg5odr pg4odr pg3odr pg2odr pg1odr pg0odr initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w pgodr is an 8-bit read/write register that stores output data for the pins on port g (pg7 to pg0). pgodr can always be read from or written to, regardless of the pgddr settings. pgodr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. port g input data register (pgpin) bit 76543210 pg7pin pg6pin pg5pin pg4pin pg3pin pg2pin pg1pin pg0pin initial value * * * * * * * * read/write r r rrrrrr note: * determined by the state of pins pg7 to pg0. reading pgpin always returns the pin states. pgpin is at the same address as pgddr. writing is to pgddr and the port g settings will change unless the given byte represents the current settings.
268 port g nch-od control register (pgnocr) bit 76543210 pg7noc pg6noc pg5noc pg4noc pg3noc pg2noc pg1noc pg0noc initial value 0 0 000000 read/write r/w r/w r/w r/w r/w r/w r/w r/w pgnocr is an 8-bit read/write register, the individual bits of which specify the output driver type for pins on port g which are configured as outputs. setting a penocr or pfnocr bit to 1 disables the p-channel driver for the corresponding pin on port g. clearing the bit to 0 enables the p-channel driver for the pin. although the p-channel drivers are always connected, the output driver type will look like cmos when the bit is cleared to 0 and n-channel open-drain when it is set to 1. pgnocr is initialized to h'00 by a reset and in hardware standby mode. it retains its prior state in software standby mode. ddr 0 1 nocr 0 1 odr 0 1 0 1 0 1 n-ch. driver off on off on off p-ch. driver off off on off mos input pul-up off on off 8.16.3 pin functions the port g pins have only one special function. 8.16.4 mos input pull-up function port g has a built-in mos input pull-up function that can be controlled by software. this mos input pull-up function can be switched on or off on a bit-by-bit basis. when a pgddr bit is cleared to 0, setting the corresponding pgodr bit to 1 will turn on the mos input pull-up for that pin. the mos input pull-up function is off after a reset and in hardware standby mode. the prior state is retained when in software standby mode. table 8.32 is a summary of the mos input pull-up states.
269 table 8.32 mos input pull-up states (port g) mode reset hardware standby mode software standby mode other operations 1, 2, 3 off off on/off on/off legend: off: mos input pull-up is always off. on/off: on when pgddr = 0 and pgodr = 1; otherwise off.
270
271 section 9 8-bit pwm timers 9.1 overview the h8s/2169 or h8/2149 has an on-chip pulse width modulation (pwm) timer module with sixteen outputs. sixteen output waveforms are generated from a common time base, enabling pwm output with a high carrier frequency to be produced using pulse division. the pwm timer module has sixteen 8-bit pwm data registers (pwdrs), and an output pulse with a duty cycle of 0 to 100% can be obtained as specified by pwdr and the port data register (p1dr or p2dr). 9.1.1 features the pwm timer module has the following features. ? operable at a maximum carrier frequency of 625 khz using pulse division (at 10 mhz operation) ? duty cycles from 0 to 100% with 1/256 resolution (100% duty realized by port output) ? direct or inverted pwm output, and pwm output enable/disable control
272 9.1.2 block diagram figure 9.1 shows a block diagram of the pwm timer module. pwdr0 pwdr1 pwdr2 pwdr3 pwdr4 pwdr5 pwdr6 pwdr7 pwdr8 pwdr9 pwdr10 pwdr11 pwdr12 pwdr13 pwdr14 pwdr15 p10/pw0 p11/pw1 p12/pw2 p13/pw3 p14/pw4 p15/pw5 p16/pw6 p17/pw7 p20/pw8 p21/pw9 p22/pw10 p23/pw11 p24/pw12 p25/pw13 p26/pw14 p27/pw15 port/pwm output control comparator 0 comparator 1 comparator 2 comparator 3 comparator 4 comparator 5 comparator 6 comparator 7 comparator 8 comparator 9 comparator 10 comparator 11 comparator 12 comparator 13 comparator 14 comparator 15 pwdprb pwoerb p2ddr p2dr pwdpra pwoera p1ddr p1dr module data bus bus interface internal data bus pwsl clock selection internal clock ?2 legend: pwsl: pwdr: pwdpra: pwdprb: pwoera: pwoerb: pcsr: p1ddr: p2ddr: p1dr: p2dr: pwm register select pwm data register pwm data polarity register a pwm data polarity register b pwm output enable register a pwm output enable register b peripheral clock select register port 1 data direction register port 2 data direction register port 1 data register port 2 data register tcnt pcsr ?4 ?8 ?16 figure 9.1 block diagram of pwm timer module
273 9.1.3 pin configuration table 9.1 shows the pwm output pin. table 9.1 pin configuration name abbreviation i/o function pwm output pin 0 to 15 pw0 to pw15 output pwm timer pulse output 0 to 15 9.1.4 register configuration table 9.2 lists the registers of the pwm timer module. table 9.2 pwm timer module registers name abbreviation r/w initial value address * 1 pwm register select pwsl r/w h'20 h'ffd6 pwm data registers 0 to 15 pwdr0 to pwdr15 r/w h'00 h'ffd7 pwm data polarity register a pwdpra r/w h'00 h'ffd5 pwm data polarity register b pwdprb r/w h'00 h'ffd4 pwm output enable register a pwoera r/w h'00 h'ffd3 pwm output enable register b pwoerb r/w h'00 h'ffd2 port 1 data direction register p1ddr w h'00 h'ffb0 port 2 data direction register p2ddr w h'00 h'ffb1 port 1 data register p1dr r/w h'00 h'ffb2 port 2 data register p2dr r/w h'00 h'ffb3 peripheral clock select register pcsr r/w h'00 h'ff82 * 2 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 note: 1. lower 16 bits of the address. 2. some pwm timer module registers are assigned to the same addresses as other registers. in this case, registers selection is performed by the flshe bit in the serial timer control register (stcr).
274 9.2 register descriptions 9.2.1 pwm register select (pwsl) bit initial value read/write 7 pwcke 0 r/w 6 pwcks 0 r/w 5 1 4 0 3 rs3 0 r/w 0 rs0 0 r/w 2 rs2 0 r/w 1 rs1 0 r/w pwsl is an 8-bit readable/writable register used to select the pwm timer input clock and the pwm data register. pwsl is initialized to h'20 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 and 6?wm clock enable, pwm clock select (pwcke, pwcks): these bits, together with bits pwcka and pwckb in pcsr, select the internal clock input to tcnt in the pwm timer. pwsl pcsr bit 7 bit 6 bit 2 bit 1 pwcke pwcks pwckb pwcka description 0 clock input is disabled (initial value) 1 0 (system clock) is selected 1 0 0 ?2 is selected 1 ?4 is selected 1 0 ?8 is selected 1 ?16 is selected the pwm resolution, pwm conversion period, and carrier frequency depend on the selected internal clock, and can be found from the following equations. resolution (minimum pulse width) = 1/internal clock frequency pwm conversion period = resolution 256 carrier frequency = 16/pwm conversion period thus, with a 10 mhz system clock (?, the resolution, pwm conversion period, and carrier frequency are as shown followings.
275 table 9.3 resolution, pwm conversion period, and carrier frequency when ?= 10 mhz internal clock frequency resolution pwm conversion period carrier frequency 100 ns 25.6 m s 625 khz ?2 200 ns 51.2 m s 312.5 khz ?4 400 ns 102.4 m s 156.3 khz ?8 800 ns 204.8 m s 78.1 khz ?16 1600 ns 409.6 m s 39.1 khz bit 5?eserved: this bit is always read as 1 and cannot be modified. bit 4?eserved: this bit is always read as 0 and cannot be modified. bits 3 to 0?egister select (rs3 to rs0): these bits select the pwm data register. bit 3 bit 2 bit 1 bit 0 rs3 rs2 rs1 rs0 register selection 0000 pwdr0 selected 1 pwdr1 selected 1 0 pwdr2 selected 1 pwdr3 selected 1 0 0 pwdr4 selected 1 pwdr5 selected 1 0 pwdr6 selected 1 pwdr7 selected 1000 pwdr8 selected 1 pwdr9 selected 1 0 pwdr10 selected 1 pwdr11 selected 1 0 0 pwdr12 selected 1 pwdr13 selected 1 0 pwdr14 selected 1 pwdr15 selected
276 9.2.2 pwm data registers (pwdr0 to pwdr15) bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w each pwdr is an 8-bit readable/writable register that specifies the duty cycle of the basic pulse to be output, and the number of additional pulses. the value set in pwdr corresponds to a 0 or 1 ratio in the conversion period. the upper 4 bits specify the duty cycle of the basic pulse as 0/16 to 15/16 with a resolution of 1/16. the lower 4 bits specify how many extra pulses are to be added within the conversion period comprising 16 basic pulses. thus, a specification of 0/256 to 255/256 is possible for 0/1 ratios within the conversion period. for 256/256 (100%) output, port output should be used. pwdr is initialized to h'00 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. 9.2.3 pwm data polarity registers a and b (pwdpra and pwdprb) pwdpra bit initial value read/write 7 os7 0 r/w 6 os6 0 r/w 5 os5 0 r/w 4 os4 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w pwdprb bit initial value read/write 7 os15 0 r/w 6 os14 0 r/w 5 os13 0 r/w 4 os12 0 r/w 3 os11 0 r/w 0 os8 0 r/w 2 os10 0 r/w 1 os9 0 r/w each pwdpr is an 8-bit readable/writable register that controls the polarity of the pwm output. bits os0 to os15 correspond to outputs pw0 to pw15. pwdpr is initialized to h'00 by a reset and in hardware standby mode.
277 os description 0 pwm direct output (pwdr value corresponds to high width of output) (initial value) 1 pwm inverted output (pwdr value corresponds to low width of output) 9.2.4 pwm output enable registers a and b (pwoera and pwoerb) pwoera bit initial value read/write 7 oe7 0 r/w 6 oe6 0 r/w 5 oe5 0 r/w 4 oe4 0 r/w 3 oe3 0 r/w 0 oe0 0 r/w 2 oe2 0 r/w 1 oe1 0 r/w pwoerb bit initial value read/write 7 oe15 0 r/w 6 oe14 0 r/w 5 oe13 0 r/w 4 oe12 0 r/w 3 oe11 0 r/w 0 oe8 0 r/w 2 oe10 0 r/w 1 oe9 0 r/w each pwoer is an 8-bit readable/writable register that switches between pwm output and port output. bits oe15 to oe0 correspond to outputs pw15 to pw0. to set a pin in the output state, a setting in the port direction register is also necessary. bits p17ddr to p10ddr correspond to outputs pw7 to pw0, and bits p27ddr to p20ddr correspond to outputs pw15 to pw8. pwoer is initialized to h'00 by a reset and in hardware standby mode. ddr oe description 0 0 port input (initial value) 1 port input 1 0 port output or pwm 256/256 output 1 pwm output (0 to 255/256 output)
278 9.2.5 peripheral clock select register (pcsr) bit initial value read/write 7 0 6 0 5 0 4 0 3 0 0 0 2 pwckb 0 r/w 1 pwcka 0 r/w pcsr is an 8-bit readable/writable register that selects the pwm timer input clock. pcsr is initialized to h'00 by a reset, and in hardware standby mode. bits 7 to 3?eserved: these bits cannot be modified and are always read as 0. bits 2 and 1?wm clock select (pwckb, pwcka): together with bits pwcke and pwcks in pwsl, these bits select the internal clock input to tcnt in the pwm timer. for details, see section 9.2.1, pwm register select (pwsl). bit 0?eserved: do not set this bit to 1. 9.2.6 port 1 data direction register (p1ddr) bit initial value read/write 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w p1ddr is an 8-bit write-only register that specifies the input/output direction and pwm output for each pin of port 1 on a bit-by-bit basis. port 1 pins are multiplexed with pins pw0 to pw7. the bit corresponding to a pin to be used for pwm output should be set to 1. for details on p1ddr, see section 8.2, port 1.
279 9.2.7 port 2 data direction register (p2ddr) bit initial value read/write 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w p2ddr is an 8-bit write-only register that specifies the input/output direction and pwm output for each pin of port 2 on a bit-by-bit basis. port 2 pins are multiplexed with pins pw8 to pw15. the bit corresponding to a pin to be used for pwm output should be set to 1. for details on p2ddr, see section 8.3, port 2. 9.2.8 port 1 data register (p1dr) bit initial value read/write 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w p1dr is an 8-bit readable/writable register used to fix pwm output at 1 (when os = 0) or 0 (when os = 1). for details on p1dr, see section 8.2, port 1. 9.2.9 port 2 data register (p2dr) bit initial value read/write 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w p2dr is an 8-bit readable/writable register used to fix pwm output at 1 (when os = 0) or 0 (when os = 1). for details on p2dr, see section 8.3, port 2.
280 9.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp11 bit is set to 1, 8-bit pwm timer operation is halted and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 3?odule stop (mstp11): specifies pwm module stop mode. mstpcrh bit 3 mstp11 description 0 pwm module stop mode is cleared 1 pwm module stop mode is set (initial value)
281 9.3 operation 9.3.1 correspondence between pwm data register contents and output waveform the upper 4 bits of pwdr specify the duty cycle of the basic pulse as 0/16 to 15/16 with a resolution of 1/16, as shown in table 9.4. table 9.4 duty cycle of basic pulse 0123456789abc d ef0 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 upper 4 bits basic pulse waveform (internal)
282 the lower 4 bits of pwdr specify the position of pulses added to the 16 basic pulses, as shown in table 9.5. an additional pulse consists of a high period (when os = 0) with a width equal to the resolution, added before the rising edge of a basic pulse. when the upper 4 bits of pwdr are 0000, there is no rising edge of the basic pulse, but the timing for adding pulses is the same. table 9.5 position of pulses added to basic pulses basic pulse no. lower 4 bits 0123456789101112131415 0000 0001 yes 0010 yes yes 0011 yes yes yes 0100 yes yes yes yes 0101 yes yes yes yes yes 0110 yes yes yes yes yes yes 0111 yes yes yes yes yes yes yes 1000 yes yes yes yes yes yes yes yes 1001 yes yes yes yes yes yes yes yes yes 1010 yes yes yes yes yes yes yes yes yes yes 1011 yes yes yes yes yes yes yes yes yes yes yes 1100 yes yes yes yes yes yes yes yes yes yes yes yes 1101 yes yes yes yes yes yes yes yes yes yes yes yes yes 1110 yes yes yes yes yes yes yes yes yes yes yes yes yes yes 1111 yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes additional pulse provided no additional pulse resolution width additional pulse figure 9.2 example of additional pulse timing (when upper 4 bits of pwdr = 1000)
283 section 10 14-bit pwm timer 10.1 overview the h8s/2169 or h8s/2149 has an on-chip 14-bit pulse-width modulator (pwm) with two output channels. each channel can be connected to an external low-pass filter to operate as a 14-bit d/a converter. both channels share the same counter (dacnt) and control register (dacr). 10.1.1 features the features of the 14-bit pwm (d/a) are listed below. the pulse is subdivided into multiple base cycles to reduce ripple. two resolution settings and two base cycle settings are available the resolution can be set equal to one or two system clock cycles. the base cycle can be set equal to t 64 or t 256, where t is the resolution. four operating rates the two resolution settings and two base cycle settings combine to give a selection of four operating rates.
284 10.1.2 block diagram figure 10.1 shows a block diagram of the pwm d/a module. internal clock ?2 pwx0 pwx1 dadra dadrb dacnt dacr legend: dacr: pwm d/a control register ( 6 bits) dadra: pwm d/a data register a (15 bits) dadrb: pwm d/a data register b (15 bits) dacnt: pwm d/a counter (14 bits) control logic clock selection clock internal data bus basic cycle compare-match a fine-adjustment pulse addition a basic cycle compare-match b fine-adjustment pulse addition b basic cycle overflow comparator a comparator b bus interface module data bus figure 10.1 pwm d/a block diagram 10.1.3 pin configuration table 10.1 lists the pins used by the pwm (d/a) module. table 10.1 input and output pins name abbreviation i/o function pwm output pin 0 pwx0 output pwm output, channel a pwm output pin 1 pwx1 output pwm output, channel b
285 10.1.4 register configuration table 10.2 lists the registers of the pwm (d/a) module. table 10.2 register configuration name abbreviation r/w initial value address * 1 pwm (d/a) control register dacr r/w h'30 h'ffa0 * 2 pwm (d/a) data register a high dadrah r/w h'ff h'ffa0 * 2 pwm (d/a) data register a low dadral r/w h'ff h'ffa1 * 2 pwm (d/a) data register b high dadrbh r/w h'ff h'ffa6 * 2 pwm (d/a) data register b low dadrbl r/w h'ff h'ffa7 * 2 pwm (d/a) counter high dacnth r/w h'00 h'ffa6 * 2 pwm (d/a) counter low dacntl r/w h'03 h'ffa7 * 2 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. some of the pwm registers are located in the same addresses as other registers, switching is made by setting iice bit in serial/timer control register (stcr). the same addresses are shared by dadrah and dacr, and by dadrb and dacnt. switching is performed by the regs bit in dacnt or dadrb. 10.2 register descriptions 10.2.1 pwm (d/a) counter (dacnt) 15 7 0 r/w 14 6 0 r/w 13 5 0 r/w 12 4 0 r/w 11 3 0 r/w 8 0 0 r/w 10 2 0 r/w 9 1 0 r/w bit (cpu) bit (counter) initial value read/write 7 8 0 r/w 6 9 0 r/w 5 10 0 r/w 4 11 0 r/w 3 12 0 r/w 0 regs 1 r/w 2 13 0 r/w 1 1 dacnth dacntl dacnt is a 14-bit readable/writable up-counter that increments on an input clock pulse. the input clock is selected by the clock select bit (cks) in dacr. the cpu can read and write the dacnt value, but since dacnt is a 16-bit register, data transfers between it and the cpu are performed using a temporary register (temp). see section 10.3, bus master interface, for details.
286 dacnt functions as the time base for both pwm (d/a) channels. when a channel operates with 14-bit precision, it uses all dacnt bits. when a channel operates with 12-bit precision, it uses the lower 12 (counter) bits and ignores the upper two (counter) bits. dacnt is initialized to h'0003 by a reset, in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode, and by the pwme bit. bit 1 of dacntl (cpu) is not used, and is always read as 1. dacntl bit 0?egister select (regs): dadra and dacr, and dadrb and dacnt, are located at the same addresses. the regs bit specifies which registers can be accessed. the regs bit can be accessed regardless of whether dadrb or dacnt is selected. bit 0 regs description 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed (initial value) 10.2.2 d/a data registers a and b (dadra and dadrb) 15 13 da13 1 r/w 14 12 da12 1 r/w 13 11 da11 1 r/w 12 10 da10 1 r/w 11 9 da9 1 r/w 8 6 da6 1 r/w 10 8 da8 1 r/w 9 7 da7 1 r/w bit (cpu) bit (data) dadra initial value read/write 7 5 da5 1 r/w 6 4 da4 1 r/w 5 3 da3 1 r/w 4 2 da2 1 r/w 3 1 da1 1 r/w 0 1 2 0 da0 1 r/w 1 cfs 1 r/w dadrh dadrl da13 1 r/w da12 1 r/w da11 1 r/w da10 1 r/w da9 1 r/w da6 1 r/w da8 1 r/w da7 1 r/w dadrb initial value read/write da5 1 r/w da4 1 r/w da3 1 r/w da2 1 r/w da1 1 r/w regs 1 r/w da0 1 r/w cfs 1 r/w there are two 16-bit readable/writable d/a data registers: dadra and dadrb. dadra corresponds to pwm (d/a) channel a, and dadrb to pwm d/a channel b. the cpu can read and write the pwm d/a data register values, but since dadra and dadrb are 16-bit registers, data transfers between them and the cpu are performed using a temporary register (temp). see section 10.3, bus master interface, for details. the least significant (cpu) bit of dadra is not used and is always read as 1. dadr is initialized to h'ffff by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode.
287 bits 15 to 2?wm d/a data 13 to 0 (da13 to da0): the digital value to be converted to an analog value is set in the upper 14 bits of the pwm (d/a) data register. in each base cycle, the dacnt value is continually compared with these upper 14 bits to determine the duty cycle of the output waveform, and to decide whether to output a fine- adjustment pulse equal in width to the resolution. to enable this operation, the data register must be set within a range that depends on the carrier frequency select bit (cfs). if the dadr value is outside this range, the pwm output is held constant. a channel can be operated with 12-bit precision by keeping the two lowest data bits (da0 and da1) cleared to 0 and writing the data to be converted in the upper 12 bits. the two lowest data bits correspond to the two highest counter (dacnt) bits. bit 1?arrier frequency select (cfs) bit 1 cfs description 0 base cycle = resolution (t) 64 dadr range = h'0401 to h'fffd 1 base cycle = resolution (t) 256 dadr range = h'0103 to h'ffff (initial value) dadra bit 0?eserved: this bit cannot be modified and is always read as 1. dadrb bit 0?egister select (regs): dadra and dacr, and dadrb and dacnt, are located at the same addresses. the regs bit specifies which registers can be accessed. the regs bit can be accessed regardless of whether dadrb or dacnt is selected. bit 0 regs description 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed (initial value) 10.2.3 pwm (d/a) control register (dacr) 7 test 0 r/w 6 pwme 0 r/w 5 1 4 1 3 oeb 0 r/w 0 cks 0 r/w 2 oea 0 r/w 1 os 0 r/w bit initial value read/write
288 dacr is an 8-bit readable/writable register that selects test mode, enables the pwm outputs, and selects the output phase and operating speed. dacr is initialized to h'30 by a reset, and in the standby modes, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7?est mode (test): selects test mode, which is used in testing the chip. normally this bit should be cleared to 0. bit 7 test description 0 pwm (d/a) in user state: normal operation (initial value) 1 pwm (d/a) in test state: correct conversion results unobtainable bit 6?wm enable (pwme): starts or stops the pwm (d/a) counter (dacnt). bit 6 pwme description 0 dacnt operates as a 14-bit up-counter (initial value) 1 dacnt halts at h'0003 bits 5 and 4?eserved: these bits cannot be modified and are always read as 1. bit 3?utput enable b (oeb): enables or disables output on pwm (d/a) channel b. bit 3 oeb description 0 pwm (d/a) channel b output (at the pwx1 pin) is disabled (initial value) 1 pwm (d/a) channel b output (at the pwx1 pin) is enabled bit 2?utput enable a (oea): enables or disables output on pwm (d/a) channel a. bit 2 oea description 0 pwm (d/a) channel a output (at the pwx0 pin) is disabled (initial value) 1 pwm (d/a) channel a output (at the pwx0 pin) is enabled
289 bit 1?utput select (os): selects the phase of the pwm (d/a) output. bit 1 os description 0 direct pwm output (initial value) 1 inverted pwm output bit 0?lock select (cks): selects the pwm (d/a) resolution. if the system clock (? frequency is 10 mhz, resolutions of 100 ns and 200 ns can be selected. bit 0 cks description 0 operates at resolution (t) = system clock cycle time (t cyc ) (initial value) 1 operates at resolution (t) = system clock cycle time (t cyc ) 2 10.2.4 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp11 bit is set to 1, 14-bit pwm timer operation is halted and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 3?odule stop (mstp11): specifies pwmx module stop mode. mstpcrh bit 3 mstp11 description 0 pwmx module stop mode is cleared 1 pwmx module stop mode is set (initial value)
290 10.3 bus master interface dacnt, dadra, and dadrb are 16-bit registers. the data bus linking the bus master and the on-chip supporting modules, however, is only 8 bits wide. when the bus master accesses these registers, it therefore uses an 8-bit temporary register (temp). these registers are written and read as follows (taking the example of the cpu interface). write when the upper byte is written, the upper-byte write data is stored in temp. next, when the lower byte is written, the lower-byte write data and temp value are combined, and the combined 16-bit value is written in the register. read when the upper byte is read, the upper-byte value is transferred to the cpu and the lower-byte value is transferred to temp. next, when the lower byte is read, the lower-byte value in temp is transferred to the cpu. these registers should always be accessed 16 bits at a time using an mov instruction (by word access or two consecutive byte accesses), and the upper byte should always be accessed before the lower byte. correct data will not be transferred if only the upper byte or only the lower byte is accessed. also note that a bit manipulation instruction cannot be used to access these registers. figure 10.2 shows the data flow for access to dacnt. the other registers are accessed similarly. example 1: write to dacnt mov.w r0, @dacnt ; write r0 contents to dacnt example 2: read dadra mov.w @dadra, r0 ; copy contents of dadra to r0 table 10.3 read and write access methods for 16-bit registers read write register name word byte word byte dadra and dadrb yes yes yes dacnt yes yes notes: yes: permitted type of access. word access includes successive byte accesses to the upper byte (first) and lower byte (second). : this type of access may give incorrect results.
291 cpu (h'aa) upper byte bus interface module data bus upper-byte write temp (h'aa) dacntl ( ) dacnth ( ) cpu (h'57) lower byte bus interface module data bus lower-byte write temp (h'aa) dacntl (h'57) dacnth (h'aa) figure 10.2 (a) access to dacnt (cpu writes h'aa57 to dacnt)
292 cpu (h'aa) upper byte bus interface module data bus upper-byte read temp (h'57) dacntl (h'57) dacnth (h'aa) cpu (h'57) lower byte bus interface module data bus lower-byte read temp (h'57) dacntl ( ) dacnth ( ) figure 10.2 (b) access to dacnt (cpu reads h'aa57 from dacnt)
293 10.4 operation a pwm waveform like the one shown in figure 10.3 is output from the pwmx pin. when os = 0, the value in dadr corresponds to the total width (t l ) of the low (0) pulses output in one conversion cycle (256 pulses when cfs = 0, 64 pulses when cfs = 1). when os = 1, the output waveform is inverted and the dadr value corresponds to the total width (t h ) of the high (1) output pulses. figure 10.4 shows the types of waveform output available. t f t l t l = ? t ln (when os = 0) m n = 1 1 conversion cycle (t 2 14 (= 16384)) basic cycle (t 64 or t 256) t: resolution (when cfs = 0, m = 256; when cfs = 1, m = 64) figure 10.3 pwm d/a operation table 10.4 summarizes the relationships of the cks, cfs, and os bit settings to the resolution, base cycle, and conversion cycle. the pwm output remains flat unless dadr contains at least a certain minimum value. table 10.4 indicates the range of dadr settings that give an output waveform like the one in figure 10.3, and lists the conversion cycle length when low-order dadr bits are kept cleared to 0, reducing the conversion precision to 12 bits or 10 bits.
294 table 10.4 settings and operation (examples when ?= 10 mhz) fixed dadr bits bit data cks resolution t ( m s) cfs base cycle ( m s) conversion cycle ( m s) t l (if os = 0) t h (if os = 1) precision (bits) 3210 conversion cycle * ( m s) 0 0.1 0 6.4 1638.4 1. always low (or high) (dadr = h'0001 to h'03fd) 14 1638.4 2. (data value) t (dadr = h'0401 to h'fffd) 12 0 0 409.6 10 0000 102.4 1 25.6 1638.4 1. always low (or high) (dadr = h'0003 to h'00ff) 14 1638.4 2. (data value) t (dadr = h'0103 to h'ffff) 12 0 0 409.6 10 0000 102.4 1 0.2 0 12.8 3276.8 1. always low (or high) (dadr = h'0001 to h'03fd) 14 3276.8 2. (data value) t (dadr = h'0401 to h'fffd) 12 0 0 819.2 10 0000 204.8 1 51.2 3276.8 1. always low (or high) (dadr = h'0003 to h'00ff) 14 3276.8 2. (data value) t (dadr = h'0103 to h'ffff) 12 0 0 819.2 10 0000 204.8 note: * this column indicates the conversion cycle when specific dadr bits are fixed.
295 1. os = 0 (dadr corresponds to t l ) a. cfs = 0 [base cycle = resolution (t) 64] t l1 t l2 t l3 t l255 t l256 t f1 t f2 t f255 t f256 1 conversion cycle t f1 = t f2 = t f3 = = t f255 = t f256 = t 64 t l1 + t l2 + t l3 + + t l255 + t l256 = t l figure 10.4 (1) output waveform b. cfs = 1 [base cycle = resolution (t) 256] t l1 t l2 t l3 t l63 t l64 t f1 t f2 t f63 t f64 1 conversion cycle t f1 = t f2 = t f3 = = t f63 = t f64 = t 256 t l1 + t l2 + t l3 + + t l63 + t l64 = t l figure 10.4 (2) output waveform
296 2. os = 1 (dadr corresponds to t h ) a. cfs = 0 [base cycle = resolution (t) 64] t h1 t h2 t h3 t h255 t h256 t f1 t f2 t f255 t f256 1 conversion cycle t f1 = t f2 = t f3 = = t f255 = t f256 = t 64 t h1 + t h2 + t h3 + + t h255 + t h256 = t h figure 10.4 (3) output waveform b. cfs = 1 [base cycle = resolution (t) 256] t h1 t h2 t h3 t h63 t h64 t f1 t f2 t f63 t f64 1 conversion cycle t f1 = t f2 = t f3 = = t f63 = t f64 = t 256 t h1 + t h2 + t h3 + + t h63 + t h64 = t h figure 10.4 (4) output waveform
297 section 11 16-bit free-running timer 11.1 overview the h8s/2169 or h8s/2149 has a single-channel on-chip 16-bit free-running timer (frt) module that uses a 16-bit free-running counter as a time base. applications of the frt module include rectangular-wave output (up to two independent waveforms), input pulse width measurement, and measurement of external clock periods. 11.1.1 features the features of the free-running timer module are listed below. ? selection of four clock sources ? the free-running counter can be driven by an internal clock source (?2, ?8, or ?32), or an external clock input (enabling use as an external event counter). ? two independent comparators ? each comparator can generate an independent waveform. ? four input capture channels ? the current count can be captured on the rising or falling edge (selectable) of an input signal. ? the four input capture registers can be used separately, or in a buffer mode. ? counter can be cleared under program control ? the free-running counters can be cleared on compare-match a. ? seven independent interrupts ? two compare-match interrupts, four input capture interrupts, and one overflow interrupt can be requested independently. ? special functions provided by automatic addition function ? the contents of ocrar and ocraf can be added to the contents of ocra automatically, enabling a periodic waveform to be generated without software intervention. ? the contents of icrd can be added automatically to the contents of ocrdm 2, enabling input capture operations in this interval to be restricted.
298 11.1.2 block diagram figure 11.1 shows a block diagram of the free-running timer. external clock source internal clock sources clock select comparator a ocra (h/l) comparator b ocrb (h/l) bus interface internal data bus ?2 ?8 ?32 ftci compare- match a clear clock ftoa ftob overflow icra (h/l) compare- match b input capture frc (h/l) tcsr ftia ftib ftic ftid control logic module data bus tier tcr tocr interrupt signals icia icib icic icid ocia ocib fovi legend: ocra, b: frc: icra, b, c, d: tcsr: output compare register a, b (16 bits) free-running counter (16 bits) input capture register a, b, c, d (16 bits) timer control/status re g ister (8 bits) tier: tcr: tocr: timer interrupt enable register (8 bits) timer control register (8 bits) timer output compare control re g ister (8 bits) icrb (h/l) icrc (h/l) icrd (h/l) ocra r/f (h/l) + + ocrdm l 1 2 comparator m compare-match m figure 11.1 block diagram of 16-bit free-running timer
299 11.1.3 input and output pins table 11.1 lists the input and output pins of the free-running timer module. table 11.1 input and output pins of free-running timer module name abbreviation i/o function counter clock input ftci input frc counter clock input output compare a ftoa output output compare a output output compare b ftob output output compare b output input capture a ftia input input capture a input input capture b ftib input input capture b input input capture c ftic input input capture c input input capture d ftid input input capture d input
300 11.1.4 register configuration table 11.2 lists the registers of the free-running timer module. table 11.2 register configuration name abbreviation r/w initial value address * 1 timer interrupt enable register tier r/w h'01 h'ff90 timer control/status register tcsr r/(w) * 2 h'00 h'ff91 free-running counter frc r/w h'0000 h'ff92 output compare register a ocra r/w h'ffff h'ff94 * 3 output compare register b ocrb r/w h'ffff h'ff94 * 3 timer control register tcr r/w h'00 h'ff96 timer output compare control register tocr r/w h'00 h'ff97 input capture register a icra r h'0000 h'ff98 * 4 input capture register b icrb r h'0000 h'ff9a * 4 input capture register c icrc r h'0000 h'ff9c * 4 input capture register d icrd r h'0000 h'ff9e output compare register ar ocrar r/w h'ffff h'ff98 * 4 output compare register af ocraf r/w h'ffff h'ff9a * 4 output compare register dm ocrdm r/w h'0000 h'ff9c * 4 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. bits 7 to 1 are read-only; only 0 can be written to clear the flags. bit 0 is readable/writable. 3. ocra and ocrb share the same address. access is controlled by the ocrs bit in tocr. 4. icra, icrb, and icrc share the same addresses with ocrar, ocraf, and ocrdm. access is controlled by the icrs bit in tocr.
301 11.2 register descriptions 11.2.1 free-running counter (frc) bit initial 15 0 r/w 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w value write read/ frc is a 16-bit readable/writable up-counter that increments on an internal pulse generated from a clock source. the clock source is selected by bits cks1 and cks0 in tcr. frc can also be cleared by compare-match a. when frc overflows from h'ffff to h'0000, the overflow flag (ovf) in tcsr is set to 1. frc is initialized to h'0000 by a reset and in hardware standby mode. 11.2.2 output compare registers a and b (ocra, ocrb) bit initial 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w value write read/ ocra and ocrb are 16-bit readable/writable registers, the contents of which are continually compared with the value in the frc. when a match is detected, the corresponding output compare flags (ocfa or ocfb) is set in tcsr. in addition, if the output enable bit (oea or oeb) in tocr is set to 1, when ocr and frc values match, the logic level selected by the output level bit (olvla or olvlb) in tocr is output at the output compare pin (ftoa or ftob). following a reset, the ftoa and ftob output levels are 0 until the first compare-match. ocr is initialized to h'ffff by a reset and in hardware standby mode.
302 11.2.3 input capture registers a to d (icra to icrd) bit initial 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 10 0 r 9 0 r 8 0 r 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 2 0 r 1 0 r 0 0 r value write read/ there are four input capture registers, a to d, each of which is a 16-bit read-only register. when the rising or falling edge of the signal at an input capture input pin (ftia to ftid) is detected, the current frc value is copied to the corresponding input capture register (icra to icrd). at the same time, the corresponding input capture flag (icfa to icfd) in tcsr is set to 1. the input capture edge is selected by the input edge select bits (iedga to iedgd) in tcr. icrc and icrd can be used as icra and icrb buffer registers, respectively, and made to perform buffer operations, by means of buffer enable bits a and b (bufea, bufeb) in tcr. figure 11.2 shows the connections when icrc is specified as the icra buffer register (bufea = 1). when icrc is used as the icra buffer, both rising and falling edges can be specified as transitions of the external input signal by setting iedga iedgc. when iedga = iedgc, either the rising or falling edge is designated. see table 11.3. note: the frc contents are transferred to the input capture register regardless of the value of the input capture flag (icf). bufea iedga iedgc ftia edge detect and capture signal generating circuit frc icrc icra figure 11.2 input capture buffering (example)
303 table 11.3 buffered input capture edge selection (example) iedga iedgc description 0 0 captured on falling edge of input capture a (ftia) (initial value) 1 captured on both rising and falling edges of input capture a (ftia) 10 1 captured on rising edge of input capture a (ftia) to ensure input capture, the width of the input capture pulse should be at least 1.5 system clock periods (1.5?. when triggering is enabled on both edges, the input capture pulse width should be at least 2.5 system clock periods (2.5?. icr is initialized to h'0000 by a reset and in hardware standby mode. 11.2.4 output compare registers ar and af (ocrar, ocraf) bit initial 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w value write read/ ocrar and ocraf are 16-bit readable/writable registers. when the ocrams bit in tocr is set to 1, the operation of ocra is changed to include the use of ocrar and ocraf. the contents of ocrar and ocraf are automatically added alternately to ocra, and the result is written to ocra. the write operation is performed on the occurrence of compare-match a. in the first compare-match a after the ocrams bit is set to 1, ocraf is added. the operation due to compare-match a varies according to whether the compare-match follows addition of ocrar or ocraf. the value of the olvla bit in tocr is ignored, and 1 is output on a compare-match a following addition of ocraf, while 0 is output on a compare-match a following addition of ocrar. when the ocra automatically addition function is used, do not set internal clock ?2 as the frc counter input clock together with an ocrar (or ocraf) value of h'0001 or less. ocrar and ocraf are initialized to h'ffff by a reset and in hardware standby mode.
304 11.2.5 output compare register dm (ocrdm) bit initial 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 10 0 r 9 0 r 8 0 r 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w value write read/ ocrdm is a 16-bit readable/writable register in which the upper 8 bits are fixed at h'00. when the icrdms bit in tocr is set to 1 and the contents of ocrdm are other than h'0000, the operation of icrd is changed to include the use of ocrdm. the point at which input capture d occurs is taken as the start of a mask interval. next, twice the contents of ocrdm is added to the contents of icrd, and the result is compared with the frc value. the point at which the values match is taken as the end of the mask interval. new input capture d events are disabled during the mask interval. a mask interval is not generated when the icrdms bit is set to 1 and the contents of ocrdm are h'0000. ocrdm is initialized to h'0000 by a reset and in hardware standby mode. 11.2.6 timer interrupt enable register (tier) bit initial value read/write 7 iciae 0 r/w 6 icibe 0 r/w 5 icice 0 r/w 4 icide 0 3 ociae 0 r/w 0 1 2 ocibe 0 r/w 1 ovie 0 r/w r/w tier is an 8-bit readable/writable register that enables and disables interrupts. tier is initialized to h'01 by a reset and in hardware standby mode. bit 7?nput capture interrupt a enable (iciae): selects whether to request input capture interrupt a (icia) when input capture flag a (icfa) in tcsr is set to 1. bit 7 iciae description 0 input capture interrupt request a (icia) is disabled (initial value) 1 input capture interrupt request a (icia) is enabled
305 bit 6?nput capture interrupt b enable (icibe): selects whether to request input capture interrupt b (icib) when input capture flag b (icfb) in tcsr is set to 1. bit 6 icibe description 0 input capture interrupt request b (icib) is disabled (initial value) 1 input capture interrupt request b (icib) is enabled bit 5?nput capture interrupt c enable (icice): selects whether to request input capture interrupt c (icic) when input capture flag c (icfc) in tcsr is set to 1. bit 5 icice description 0 input capture interrupt request c (icic) is disabled (initial value) 1 input capture interrupt request c (icic) is enabled bit 4?nput capture interrupt d enable (icide): selects whether to request input capture interrupt d (icid) when input capture flag d (icfd) in tcsr is set to 1. bit 4 icide description 0 input capture interrupt request d (icid) is disabled (initial value) 1 input capture interrupt request d (icid) is enabled bit 3?utput compare interrupt a enable (ociae): selects whether to request output compare interrupt a (ocia) when output compare flag a (ocfa) in tcsr is set to 1. bit 3 ociae description 0 output compare interrupt request a (ocia) is disabled (initial value) 1 output compare interrupt request a (ocia) is enabled bit 2?utput compare interrupt b enable (ocibe): selects whether to request output compare interrupt b (ocib) when output compare flag b (ocfb) in tcsr is set to 1. bit 2 ocibe description 0 output compare interrupt request b (ocib) is disabled (initial value) 1 output compare interrupt request b (ocib) is enabled
306 bit 1?imer overflow interrupt enable (ovie): selects whether to request a free-running timer overflow interrupt (fovi) when the timer overflow flag (ovf) in tcsr is set to 1. bit 1 ovie description 0 timer overflow interrupt request (fovi) is disabled (initial value) 1 timer overflow interrupt request (fovi) is enabled bit 0?eserved: this bit cannot be modified and is always read as 1. 11.2.7 timer control/status register (tcsr) bit initial value read/write 7 icfa 0 r/(w) * 6 icfb 0 r/(w) * 5 icfc 0 4 icfd 0 3 ocfa 0 0 cclra 0 r/w 2 ocfb 0 r/(w) * 1 ovf 0 r/(w) * r/(w) * r/(w) * r/(w) * note: * only 0 can be written in bits 7 to 1 to clear these flags. tcsr is an 8-bit register used for counter clear selection and control of interrupt request signals. tcsr is initialized to h'00 by a reset and in hardware standby mode. timing is described in section 11.3, operation. bit 7?nput capture flag a (icfa): this status flag indicates that the frc value has been transferred to icra by means of an input capture signal. when bufea = 1, icfa indicates that the old icra value has been moved into icrc and the new frc value has been transferred to icra. icfa must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 7 icfa description 0 [clearing condition] read icfa when icfa = 1, then write 0 in icfa (initial value) 1 [setting condition] when an input capture signal causes the frc value to be transferred to icra
307 bit 6?nput capture flag b (icfb): this status flag indicates that the frc value has been transferred to icrb by means of an input capture signal. when bufeb = 1, icfb indicates that the old icrb value has been moved into icrd and the new frc value has been transferred to icrb. icfb must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 6 icfb description 0 [clearing condition] read icfb when icfb = 1, then write 0 in icfb (initial value) 1 [setting condition] when an input capture signal causes the frc value to be transferred to icrb bit 5?nput capture flag c (icfc): this status flag indicates that the frc value has been transferred to icrc by means of an input capture signal. when bufea = 1, on occurrence of the signal transition in ftic (input capture signal) specified by the iedgc bit, icfc is set but data is not transferred to icrc. therefore, in buffer operation, icfc can be used as an external interrupt signal (by setting the icice bit to 1). icfc must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 5 icfc description 0 [clearing condition] read icfc when icfc = 1, then write 0 in icfc (initial value) 1 [setting condition] when an input capture signal is received bit 4?nput capture flag d (icfd): this status flag indicates that the frc value has been transferred to icrd by means of an input capture signal. when bufeb = 1, on occurrence of the signal transition in ftid (input capture signal) specified by the iedgd bit, icfd is set but data is not transferred to icrd. therefore, in buffer operation, icfd can be used as an external interrupt by setting the icide bit to 1. icfd must be cleared by software. it is set by hardware, however, and cannot be set by software.
308 bit 4 icfd description 0 [clearing condition] read icfd when icfd = 1, then write 0 in icfd (initial value) 1 [setting condition] when an input capture signal is received bit 3?utput compare flag a (ocfa): this status flag indicates that the frc value matches the ocra value. this flag must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 3 ocfa description 0 [clearing condition] read ocfa when ocfa = 1, then write 0 in ocfa (initial value) 1 [setting condition] when frc = ocra bit 2?utput compare flag b (ocfb): this status flag indicates that the frc value matches the ocrb value. this flag must be cleared by software. it is set by hardware, however, and cannot be set by software. bit 2 ocfb description 0 [clearing condition] read ocfb when ocfb = 1, then write 0 in ocfb (initial value) 1 [setting condition] when frc = ocrb bit 1?imer overflow flag (ovf): this status flag indicates that the frc has overflowed (changed from h'ffff to h'0000). this flag must be cleared by software. it is set by hardware, however, and cannot be set by software.
309 bit 1 ovf description 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf (initial value) 1 [setting condition] when frc changes from h'ffff to h'0000 bit 0?ounter clear a (cclra): this bit selects whether the frc is to be cleared at compare- match a (when the frc and ocra values match). bit 0 cclra description 0 frc clearing is disabled (initial value) 1 frc is cleared at compare-match a 11.2.8 timer control register (tcr) bit initial value read/write 7 iedga 0 r/w 6 iedgb 0 r/w 5 iedgc 0 r/w 4 iedgd 0 r/w 3 bufea 0 r/w 0 cks0 0 r/w 2 bufeb 0 r/w 1 cks1 0 r/w tcr is an 8-bit readable/writable register that selects the rising or falling edge of the input capture signals, enables the input capture buffer mode, and selects the frc clock source. tcr is initialized to h'00 by a reset and in hardware standby mode bit 7?nput edge select a (iedga): selects the rising or falling edge of the input capture a signal (ftia). bit 7 iedga description 0 capture on the falling edge of ftia (initial value) 1 capture on the rising edge of ftia bit 6?nput edge select b (iedgb): selects the rising or falling edge of the input capture b signal (ftib).
310 bit 6 iedgb description 0 capture on the falling edge of ftib (initial value) 1 capture on the rising edge of ftib bit 5?nput edge select c (iedgc): selects the rising or falling edge of the input capture c signal (ftic). bit 5 iedgc description 0 capture on the falling edge of ftic (initial value) 1 capture on the rising edge of ftic bit 4?nput edge select d (iedgd): selects the rising or falling edge of the input capture d signal (ftid). bit 4 iedgd description 0 capture on the falling edge of ftid (initial value) 1 capture on the rising edge of ftid bit 3?uffer enable a (bufea): selects whether icrc is to be used as a buffer register for icra. bit 3 bufea description 0 icrc is not used as a buffer register for input capture a (initial value) 1 icrc is used as a buffer register for input capture a bit 2?uffer enable b (bufeb): selects whether icrd is to be used as a buffer register for icrb. bit 2 bufeb description 0 icrd is not used as a buffer register for input capture b (initial value) 1 icrd is used as a buffer register for input capture b
311 bits 1 and 0?lock select (cks1, cks0): select external clock input or one of three internal clock sources for the frc. external clock pulses are counted on the rising edge of signals input to the external clock input pin (ftci). bit 1 bit 0 cks1 cks0 description 0 0 ?2 internal clock source (initial value) 1 ?8 internal clock source 1 0 ?32 internal clock source 1 external clock source (rising edge) 11.2.9 timer output compare control register (tocr) bit initial value read/write 7 icrdms 0 r/w 6 ocrams 0 r/w 5 icrs 0 r/w 4 ocrs 0 3 oea 0 0 olvlb 0 r/w 2 oeb 0 r/w 1 olvla 0 r/w r/w r/w tocr is an 8-bit readable/writable register that enables output from the output compare pins, selects the output levels, switches access between output compare registers a and b, controls the icrd and ocra operating mode, and switches access to input capture registers a, b, and c. tocr is initialized to h'00 by a reset and in hardware standby mode. bit 7?nput capture d mode select (icrdms): specifies whether icrd is used in the normal operating mode or in the operating mode using ocrdm. bit 7 icrdms description 0 the normal operating mode is specified for icrd (initial value) 1 the operating mode using ocrdm is specified for icrd bit 6?utput compare a mode select (ocrams): specifies whether ocra is used in the normal operating mode or in the operating mode using ocrar and ocraf.
312 bit 6 ocrams description 0 the normal operating mode is specified for ocra (initial value) 1 the operating mode using ocrar and ocraf is specified for ocra bit 5?nput capture register select (icrs): the same addresses are shared by icra and ocrar, by icrb and ocraf, and by icrc and ocrdm. the icrs bit determines which registers are selected when the shared addresses are read or written to. the operation of icra, icrb, and icrc is not affected. bit 5 icrs description 0 the icra, icrb, and icrc registers are selected (initial value) 1 the ocrar, ocraf, and ocrdm registers are selected bit 4?utput compare register select (ocrs): ocra and ocrb share the same address. when this address is accessed, the ocrs bit selects which register is accessed. this bit does not affect the operation of ocra or ocrb. bit 4 ocrs description 0 the ocra register is selected (initial value) 1 the ocrb register is selected bit 3?utput enable a (oea): enables or disables output of the output compare a signal (ftoa). bit 3 oea description 0 output compare a output is disabled (initial value) 1 output compare a output is enabled bit 2?utput enable b (oeb): enables or disables output of the output compare b signal (ftob).
313 bit 2 oeb description 0 output compare b output is disabled (initial value) 1 output compare b output is enabled bit 1?utput level a (olvla): selects the logic level to be output at the ftoa pin in response to compare-match a (signal indicating a match between the frc and ocra values). when the ocrams bit is 1, this bit is ignored. bit 1 olvla description 0 0 output at compare-match a (initial value) 1 1 output at compare-match a bit 0?utput level b (olvlb): selects the logic level to be output at the ftob pin in response to compare-match b (signal indicating a match between the frc and ocrb values). bit 0 olvlb description 0 0 output at compare-match b (initial value) 1 1 output at compare-match b 11.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp13 bit is set to 1, frt operation is stopped at the end of the bus cycle, and module stop mode is entered. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode.
314 mstpcrh bit 5?odule stop (mstp13): specifies the frt module stop mode. bit 5 mstpcrh description 0 frt module stop mode is cleared 1 frt module stop mode is set (initial value) 11.3 operation 11.3.1 frc increment timing frc increments on a pulse generated once for each period of the selected (internal or external) clock source. internal clock: any of three internal clocks (?2, ?8, or ?32) created by division of the system clock (? can be selected by making the appropriate setting in bits cks1 and cks0 in tcr. figure 11.3 shows the increment timing. n ?1 frc input clock frc internal clock n n + 1 figure 11.3 increment timing with internal clock source external clock: if external clock input is selected by bits cks1 and cks0 in tcr, frc increments on the rising edge of the external clock signal. the pulse width of the external clock signal must be at least 1.5 system clock (? periods. the counter will not increment correctly if the pulse width is shorter than 1.5 system clock periods. figure 11.4 shows the increment timing.
315 n + 1 n frc input clock frc external clock input pin figure 11.4 increment timing with external clock source 11.3.2 output compare output timing when a compare-match occurs, the logic level selected by the output level bit (olvla or olvlb) in tocr is output at the output compare pin (ftoa or ftob). figure 11.5 shows the timing of this operation for compare-match a. n + 1 n n + 1 n n ocra compare-match a signal frc olvla output compare a output pin ftoa clear * note: * vertical arrows ( ) indicate instructions executed by software. n figure 11.5 timing of output compare a output
316 11.3.3 frc clear timing frc can be cleared when compare-match a occurs. figure 11.6 shows the timing of this operation. n h'0000 frc compare-match a signal figure 11.6 clearing of frc by compare-match a 11.3.4 input capture input timing input capture input timing: an internal input capture signal is generated from the rising or falling edge of the signal at the input capture pin, as selected by the corresponding iedgx (x = a to d) bit in tcr. figure 11.7 shows the usual input capture timing when the rising edge is selected (iedgx = 1). input capture signal input capture input pin figure 11.7 input capture signal timing (usual case) if the upper byte of icra/b/c/d is being read when the corresponding input capture signal arrives, the internal input capture signal is delayed by one system clock (? period. figure 11.8 shows the timing for this case.
317 input capture signal input capture input pin t 1 t 2 icra/b/c/d read cycle figure 11.8 input capture signal timing (input capture input when icra/b/c/d is read) buffered input capture input timing: icrc and icrd can operate as buffers for icra and icrb. figure 11.9 shows how input capture operates when icra and icrc are used in buffer mode and iedga and iedgc are set to different values (iedga = 0 and iedgc = 1, or iedg a = 1 and iedgc = 0), so that input capture is performed on both the rising and falling edges of ftia. n n + 1 n n + 1 m n n n mm mn ftia input capture signal frc icra icrc figure 11.9 buffered input capture timing (usual case)
318 when icrc or icrd is used as a buffer register, its input capture flag is set by the selected transition of its input capture signal. for example, if icrc is used to buffer icra, when the edge transition selected by the iedgc bit occurs on the ftic input capture line, icfc will be set, and if the iciec bit is set, an interrupt will be requested. the frc value will not be transferred to icrc, however. in buffered input capture, if the upper byte of either of the two registers to which data will be transferred (icra and icrc, or icrb and icrd) is being read when the input signal arrives, input capture is delayed by one system clock (? period. figure 11.10 shows the timing when bufea = 1. input capture signal ftia t 1 t 2 read cycle: cpu reads icra or icrc figure 11.10 buffered input capture timing (input capture input when icra or icrc is read) 11.3.5 timing of input capture flag (icf) setting the input capture flag icfx (x = a, b, c, d) is set to 1 by the internal input capture signal. the frc value is simultaneously transferred to the corresponding input capture register (icrx). figure 11.11 shows the timing of this operation.
319 icfa/b/c/d frc input capture signal n n icra/b/c/d figure 11.11 setting of input capture flag (icfa/b/c/d) 11.3.6 setting of output compare flags a and b (ocfa, ocfb) the output compare flags are set to 1 by an internal compare-match signal generated when the frc value matches the ocra or ocrb value. this compare-match signal is generated at the last state in which the two values match, just before frc increments to a new value. accordingly, when the frc and ocr values match, the compare-match signal is not generated until the next period of the clock source. figure 11.12 shows the timing of the setting of ocfa and ocfb. ocra or ocrb compare-match signal frc n n + 1 n ocfa or ocfb figure 11.12 setting of output compare flag (ocfa, ocfb)
320 11.3.7 setting of frc overflow flag (ovf) the frc overflow flag (ovf) is set to 1 when frc overflows (changes from h'ffff to h'0000). figure 11.13 shows the timing of this operation. h'ffff h'0000 overflow signal frc ovf figure 11.13 setting of overflow flag (ovf) 11.3.8 automatic addition of ocra and ocrar/ocraf when the ocrams bit in tocr is set to 1, the contents of ocrar and ocraf are automatically added to ocra alternately, and when an ocra compare-match occurs a write to ocra is performed. the ocra write timing is shown in figure 11.14. ocrar, f ocra frc a n n+a compare-match signal n n+1 figure 11.14 ocra automatic addition timing
321 11.3.9 icrd and ocrdm mask signal generation when the icrdms bit in tocr is set to 1 and the contents of ocrdm are other than h'0000, a signal that masks the icrd input capture function is generated. the mask signal is set by the input capture signal. the mask signal setting timing is shown in figure 11.15. the mask signal is cleared by the sum of the icrd contents and twice the ocrdm contents, and an frc compare-match. the mask signal clearing timing is shown in figure 11.16. input capture mask signal input capture signal figure 11.15 input capture mask signal setting timing compare-match signal icrd + ocrdm 2 frc n input capture mask signal n n+1 figure 11.16 input capture mask signal clearing timing
322 11.4 interrupts the free-running timer can request seven interrupts (three types): input capture a to d (icia, icib, icic, icid), output compare a and b (ocia and ocib), and overflow (fovi). each interrupt can be enabled or disabled by an enable bit in tier. independent signals are sent to the interrupt controller for each interrupt. table 11.4 lists information about these interrupts. table 11.4 free-running timer interrupts interrupt description dtc activation priority icia requested by icfa possible high icib requested by icfb possible icic requested by icfc not possible icid requested by icfd not possible ocia requested by ocfa possible ocib requested by ocfb possible fovi requested by ovf not possible low 11.5 sample application in the example below, the free-running timer is used to generate pulse outputs with a 50% duty cycle and arbitrary phase relationship. the programming is as follows: ? the cclra bit in tcsr is set to 1. ? each time a compare-match interrupt occurs, software inverts the corresponding output level bit in tocr (olvla or olvlb). frc counter clear h'ffff ocra ocrb h'0000 ftoa ftob figure 11.17 pulse output (example)
323 11.6 usage notes application programmers should note that the following types of contention can occur in the free- running timer. contention between frc write and clear: if an internal counter clear signal is generated during the state after an frc write cycle, the clear signal takes priority and the write is not performed. figure 11.18 shows this type of contention. t 1 t 2 frc write cycle address frc address internal write signal counter clear signal frc n h'0000 figure 11.18 frc write-clear contention
324 contention between frc write and increment: if an frc increment pulse is generated during the state after an frc write cycle, the write takes priority and frc is not incremented. figure 11.19 shows this type of contention. t 1 t 2 frc write cycle address internal write signal frc input clock frc n m write data frc address figure 11.19 frc write-increment contention
325 contention between ocr write and compare-match: if a compare-match occurs during the state after an ocra or ocrb write cycle, the write takes priority and the compare-match signal is inhibited. figure 11.20 shows this type of contention. if automatic addition of ocrar/ocraf to ocra is selected, and a compare-match occurs in the cycle following the ocra, ocrar and ocraf write cycle, the ocra, ocrar and ocraf write takes priority and the compare-match signal is inhibited. consequently, the result of the automatic addition is not written to ocra. figure 11.21 shows this timing t 1 t 2 ocra or ocrb write cycle address internal write signal frc ocr n m write data ocr address n n + 1 compare-match signal inhibited figure 11.20 contention between ocr write and compare-match (when automatic addition function is not used)
326 f address ocrar ( ocraf ) address internal write signal frc compare-match signal is inhibited and automatic addition does not occur. ocra n n n + 1 compare-match signal inhibited ocrar (ocraf) old data new data figure 11.21 contention between ocrar/ocraf write and compare-match (when automatic addition function is used)
327 switching of internal clock and frc operation: when the internal clock is changed, the changeover may cause frc to increment. this depends on the time at which the clock select bits (cks1 and cks0) are rewritten, as shown in table 11.5. when an internal clock is used, the frc clock is generated on detection of the falling edge of the internal clock scaled from the system clock (?. if the clock is changed when the old source is high and the new source is low, as in case no. 3 in table 11.5, the changeover is regarded as a falling edge that triggers the frc increment clock pulse. switching between an internal and external clock can also cause frc to increment. table 11.5 switching of internal clock and frc operation no. timing of switchover by means of cks1 and cks0 bits frc operation 1 switching from low to low n + 1 clock before switchover clock after switchover frc clock frc cks bit rewrite n 2 switching from low to high n + 1 n + 2 clock before switchover clock after switchover frc clock frc cks bit rewrite n
328 no. timing of switchover by means of cks1 and cks0 bits frc operation 3 switching from high to low n + 1 n n + 2 * clock before switchover clock after switchover frc clock frc cks bit rewrite 4 switching from high to high n + 1 n + 2 n clock before switchover clock after switchover frc clock cks bit rewrite frc note: * generated on the assumption that the switchover is a falling edge; frc is incremented.
329 section 12 8-bit timers 12.1 overview the h8s/2169 or h8s/2149 includes an 8-bit timer module with two channels (tmr0 and tmr1). each channel has an 8-bit counter (tcnt) and two time constant registers (tcora and tcorb) that are constantly compared with the tcnt value to detect compare-matches. the 8-bit timer module can be used as a multifunction timer in a variety of applications, such as generation of a rectangular-wave output with an arbitrary duty cycle. the h8s/2169 or h8s/2149 also has two similar 8-bit timer channels (tmrx and tmry). these channels can be used in a connected configuration using the timer connection function. tmrx and tmry have greater input/output and interrupt function related restrictions than tmr0 and tmr1. 12.1.1 features ? selection of clock sources ? tmr0, tmr1: the counter input clock can be selected from six internal clocks and an external clock (enabling use as an external event counter). ? tmrx, tmry: the counter input clock can be selected from three internal clocks and an external clock (enabling use as an external event counter). ? selection of three ways to clear the counters ? the counters can be cleared on compare-match a or b, or by an external reset signal. ? timer output controlled by two compare-match signals ? the timer output signal in each channel is controlled by two independent compare-match signals, enabling the timer to be used for various applications, such as the generation of pulse output or pwm output with an arbitrary duty cycle. (note: tmry does not have a timer output pin.) ? cascading of the two channels (tmr0, tmr1) ? operation as a 16-bit timer can be performed using channel 0 as the upper half and channel 1 as the lower half (16-bit count mode). ? channel 1 can be used to count channel 0 compare-match occurrences (compare-match count mode). ? multiple interrupt sources for each channel ? tmr0, tmr1, tmry: two compare-match interrupts and one overflow interrupt can be requested independently. ? tmrx: one input capture source is available.
330 12.1.2 block diagram figure 12.1 shows a block diagram of the 8-bit timer module (tmr0 and tmr1). tmrx and tmry have a similar configuration, but cannot be cascaded. tmrx also has an input capture function. for details, see section 13, timer connection. external clock sources internal clock sources tmr0 ?8, ?2 ?64, ?32 ?1024, ?256 clock 1 clock 0 compare-match a1 compare-match a0 clear 1 cmia0 cmib0 ovi0 cmia1 cmib1 ovi1 interrupt signals tmo0 tmri0 internal bus tcora0 comparator a0 comparator b0 tcorb0 tcsr0 tcr0 tcora1 comparator a1 tcnt1 comparator b1 tcorb1 tcsr1 tcr1 tmci0 tmci1 tcnt0 overflow 1 overflow 0 compare-match b1 compare-match b0 tmo1 tmri1 clock select control logic clear 0 tmr1 ?8, ?2 ?64, ?128 ?1024, ?2048 tmrx ?2 ?4 tmry ?4 ?256 ?2048 figure 12.1 block diagram of 8-bit timer module
331 12.1.3 pin configuration table 12.1 summarizes the input and output pins of the 8-bit timer module. table 12.1 8-bit timer input and output pins channel name symbol * i/o function 0 timer output tmo0 output output controlled by compare-match timer clock input tmci0 input external clock input for the counter timer reset input tmri0 input external reset input for the counter 1 timer output tmo1 output output controlled by compare-match timer clock input tmci1 input external clock input for the counter timer reset input tmri1 input external reset input for the counter x timer output tmox output output controlled by compare-match timer clock/ reset input hfbacki/tmix (tmcix/tmrix) input external clock/reset input for the counter y timer clock/reset input vsynci/tmiy (tmciy/tmriy) input external clock/reset input for the counter note: * the abbreviations tmo, tmci, and tmri are used in the text, omitting the channel number. channel x and y i/o pins have the same internal configuration as channels 0 and 1, and therefore the same abbreviations are used.
332 12.1.4 register configuration table 12.2 summarizes the registers of the 8-bit timer module. table 12.2 8-bit timer registers channel name abbreviation * 3 r/w initial value address * 1 0 timer control register 0 tcr0 r/w h'00 h'ffc8 timer control/status register 0 tcsr0 r/(w) * 2 h'00 h'ffca time constant register a0 tcora0 r/w h'ff h'ffcc time constant register b0 tcorb0 r/w h'ff h'ffce time counter 0 tcnt0 r/w h'00 h'ffd0 1 timer control register 1 tcr1 r/w h'00 h'ffc9 timer control/status register 1 tcsr1 r/(w) * 2 h'10 h'ffcb time constant register a1 tcora1 r/w h'ff h'ffcd time constant register b1 tcorb1 r/w h'ff h'ffcf timer counter 1 tcnt1 r/w h'00 h'ffd1 common serial/timer control register stcr r/w h'00 h'ffc3 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 timer connection register s tconrs r/w h'00 h'fffe x timer control register x tcrx r/w h'00 h'fff0 timer control/status register x tcsrx r/(w) * 2 h'00 h'fff1 time constant register ax tcorax r/w h'ff h'fff6 time constant register bx tcorbx r/w h'ff h'fff7 timer counter x tcntx r/w h'00 h'fff4 time constant register c tcorc r/w h'ff h'fff5 input capture register r ticrr r h'00 h'fff2 input capture register f ticrf r h'00 h'fff3 y timer control register y tcry r/w h'00 h'fff0 timer control/status register y tcsry r/(w) * 2 h'00 h'fff1 time constant register ay tcoray r/w h'ff h'fff2 time constant register by tcorby r/w h'ff h'fff3 timer counter y tcnty r/w h'00 h'fff4 timer input select register tisr r/w h'fe h'fff5 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bits 7 to 5, to clear these flags. 3. the abbreviations tcr, tcsr, tcora, tcorb, and tcnt are used in the text, omitting the channel designation (0, 1, x, or y).
333 each pair of registers for channel 0 and channel 1 comprises a 16-bit register with the upper 8 bits for channel 0 and the lower 8 bits for channel 1, so they can be accessed together by word access. (access is not divided into two 8-bit accesses.) in the h8s/2169 or h8s/2149, certain of the channel x and channel y registers are assigned to the same address. the tmrx/y bit in tconrs determines which register is accessed. 12.2 register descriptions 12.2.1 timer counter (tcnt) 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w tcntx,tcnty bit initial value read/write 15 0 r/w bit initial value read/write 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w tcnt0 tcnt1 each tcnt is an 8-bit readable/writable up-counter. tcnt0 and tcnt1 comprise a single 16-bit register, so they can be accessed together by word access. tcnt increments on pulses generated from an internal or external clock source. this clock source is selected by clock select bits cks2 to cks0 in tcr. tcnt can be cleared by an external reset input signal or compare-match signal. counter clear bits cclr1 and cclr0 in tcr select the method of clearing. when tcnt overflows from h'ff to h'00, the overflow flag (ovf) in tcsr is set to 1. the timer counters are initialized to h'00 by a reset and in hardware standby mode.
334 12.2.2 time constant register a (tcora) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w tcorax, tcoray bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcora0 tcora1 tcora is an 8-bit readable/writable register. tcora0 and tcora1 comprise a single 16-bit register, so they can be accessed together by word access. tcora is continually compared with the value in tcnt. when a match is detected, the corresponding compare-match flag a (cmfa) in tcsr is set. note, however, that comparison is disabled during the t2 state of a tcora write cycle. the timer output can be freely controlled by these compare-match signals and the settings of output select bits os1 and os0 in tcsr. tcora is initialized to h'ff by a reset and in hardware standby mode.
335 12.2.3 time constant register b (tcorb) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w tcorbx, tcorby bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcorb0 tcorb1 tcorb is an 8-bit readable/writable register. tcorb0 and tcorb1 comprise a single 16-bit register, so they can be accessed together by word access. tcorb is continually compared with the value in tcnt. when a match is detected, the corresponding compare-match flag b (cmfb) in tcsr is set. note, however, that comparison is disabled during the t2 state of a tcorb write cycle. the timer output can be freely controlled by these compare-match signals and the settings of output select bits os3 and os2 in tcsr. tcorb is initialized to h'ff by a reset and in hardware standby mode. 12.2.4 timer control register (tcr) 7 cmieb 0 r/w 6 cmiea 0 r/w 5 ovie 0 r/w 4 cclr1 0 r/w 3 cclr0 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcr is an 8-bit readable/writable register that selects the clock source and the time at which tcnt is cleared, and enables interrupts. tcr is initialized to h'00 by a reset and in hardware standby mode. for details of the timing, see section 12.3, operation.
336 bit 7?ompare-match interrupt enable b (cmieb): selects whether the cmfb interrupt request (cmib) is enabled or disabled when the cmfb flag in tcsr is set to 1. note that a cmib interrupt is not requested by tmrx, regardless of the cmieb value. bit 7 cmieb description 0 cmfb interrupt request (cmib) is disabled (initial value) 1 cmfb interrupt request (cmib) is enabled bit 6?ompare-match interrupt enable a (cmiea): selects whether the cmfa interrupt request (cmia) is enabled or disabled when the cmfa flag in tcsr is set to 1. note that a cmia interrupt is not requested by tmrx, regardless of the cmiea value. bit 6 cmiea description 0 cmfa interrupt request (cmia) is disabled (initial value) 1 cmfa interrupt request (cmia) is enabled bit 5?imer overflow interrupt enable (ovie): selects whether the ovf interrupt request (ovi) is enabled or disabled when the ovf flag in tcsr is set to 1. note that an ovi interrupt is not requested by tmrx, regardless of the ovie value. bit 5 ovie description 0 ovf interrupt request (ovi) is disabled (initial value) 1 ovf interrupt request (ovi) is enabled bits 4 and 3?ounter clear 1 and 0 (cclr1, cclr0): these bits select the method by which the timer counter is cleared: by compare-match a or b, or by an external reset input. bit 4 bit 3 cclr1 cclr0 description 0 0 clearing is disabled (initial value) 1 cleared on compare-match a 1 0 cleared on compare-match b 1 cleared on rising edge of external reset input
337 bits 2 to 0?lock select 2 to 0 (cks2 to cks0): these bits select whether the clock input to tcnt is an internal or external clock. the input clock can be selected from either six or three clocks, all divided from the system clock (?. the falling edge of the selected internal clock triggers the count. when use of an external clock is selected, three types of count can be selected: at the rising edge, the falling edge, and both rising and falling edges. some functions differ between channel 0 and channel 1, because of the cascading function. tcr stcr bit 2 bit 1 bit 0 bit 1 bit 0 channel cks2 cks1 cks0 icks1 icks0 description 0 0 0 0 clock input disabled (initial value) 0 0 1 0 ?8 internal clock source, counted on the falling edge 0 0 1 1 ?2 internal clock source, counted on the falling edge 0 1 0 0 ?64 internal clock source, counted on the falling edge 0 1 0 1 ?32 internal clock source, counted on the falling edge 0 1 1 0 ?1024 internal clock source, counted on the falling edge 0 1 1 1 ?256 internal clock source, counted on the falling edge 1 0 0 counted on tcnt1 overflow signal * 1 0 0 0 clock input disabled (initial value) 0 0 1 0 ?8 internal clock source, counted on the falling edge 0 0 1 1 ?2 internal clock source, counted on the falling edge 0 1 0 0 ?64 internal clock source, counted on the falling edge 0 1 0 1 ?128 internal clock source, counted on the falling edge 0 1 1 0 ?1024 internal clock source, counted on the falling edge 0 1 1 1 ?2048 internal clock source, counted on the falling edge 1 0 0 counted on tcnt0 compare-match a *
338 tcr stcr bit 2 bit 1 bit 0 bit 1 bit 0 channel cks2 cks1 cks0 icks1 icks0 description x 0 0 0 clock input disabled (initial value) 0 0 1 counted on ?internal clock source 0 1 0 ?2 internal clock source, counted on the falling edge 0 1 1 ?4 internal clock source, counted on the falling edge 1 0 0 clock input disabled y 0 0 0 clock input disabled (initial value) 0 0 1 ?4 internal clock source, counted on the falling edge 0 1 0 ?256 internal clock source, counted on the falling edge 0 1 1 ?2048 internal clock source, counted on the falling edge 1 0 0 clock input disabled common 1 0 1 external clock source, counted at rising edge 1 1 0 external clock source, counted at falling edge 1 1 1 external clock source, counted at both rising and falling edges note: * if the clock input of channel 0 is the tcnt1 overflow signal and that of channel 1 is the tcnt0 compare-match signal, no incrementing clock will be generated. do not use this setting.
339 12.2.5 timer control/status register (tcsr) 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icie 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write note: * only 0 can be written in bits 7 to 5, and in bit 4 in tcsrx, to clear these fla g s. tcsry 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icf 0 r/(w) * 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsrx 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 1 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr1 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 adte 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr0 tcsr is an 8-bit register that indicates compare-match and overflow statuses (and input capture status in tmrx only), and controls compare-match output. tcsr0, tcsrx, and tcsry are initialized to h'00, and tcsr1 is initialized to h'10, by a reset and in hardware standby mode. bit 7?ompare-match flag b (cmfb): status flag indicating whether the values of tcnt and tcorb match.
340 bit 7 cmfb description 0 [clearing conditions] ? read cmfb when cmfb = 1, then write 0 in cmfb ? when the dtc is activated by a cmib interrupt (initial value) 1 [setting condition] when tcnt = tcorb bit 6?ompare-match flag a (cmfa): status flag indicating whether the values of tcnt and tcora match. bit 6 cmfa description 0 [clearing conditions] ? read cmfa when cmfa = 1, then write 0 in cmfa ? when the dtc is activated by a cmia interrupt (initial value) 1 [setting condition] when tcnt = tcora bit 5 ?imer overflow flag (ovf): status flag indicating that tcnt has overflowed (changed from h'ff to h'00). bit 5 ovf description 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf (initial value) 1 [setting condition] when tcnt overflows from h'ff to h'00 tcsr0 bit 4?/d trigger enable (adte): enables or disables a/d converter start requests by compare-match a. bit 4 adte description 0 a/d converter start requests by compare-match a are disabled (initial value) 1 a/d converter start requests by compare-match a are enabled
341 tcsr1 bit 4?eserved: this bit cannot be modified and is always read as 1. tcsrx bit 4?nput capture flag (icf): status flag that indicates detection of a rising edge followed by a falling edge in the external reset signal after the icst bit in tconri has been set to 1. bit 4 icf description 0 [clearing condition] read icf when icf = 1, then write 0 in icf (initial value) 1 [setting condition] when a rising edge followed by a falling edge is detected in the external reset signal after the icst bit in tconri has been set to 1 tcsry bit 4?nput capture interrupt enable (icie): selects enabling or disabling of the interrupt request by icf (icix) when the icf bit in tcsrx is set to 1. bit 4 icie description 0 interrupt request by icf (icix) is disabled (initial value) 1 interrupt request by icf (icix) is enabled bits 3 to 0?utput select 3 to 0 (os3 to os0): these bits specify how the timer output level is to be changed by a compare-match of tcor and tcnt. os3 and os2 select the effect of compare-match b on the output level, os1 and os0 select the effect of compare-match a on the output level, and both of them can be controlled independently. note, however, that priorities are set such that: trigger output > 1 output > 0 output. if compare- matches occur simultaneously, the output changes according to the compare-match with the higher priority. timer output is disabled when bits os3 to os0 are all 0. after a reset, the timer output is 0 until the first compare-match occurs.
342 bit 3 bit 2 os3 os2 description 0 0 no change when compare-match b occurs (initial value) 1 0 is output when compare-match b occurs 1 0 1 is output when compare-match b occurs 1 output is inverted when compare-match b occurs (toggle output) bit 1 bit 0 os1 os0 description 0 0 no change when compare-match a occurs (initial value) 1 0 is output when compare-match a occurs 1 0 1 is output when compare-match a occurs 1 output is inverted when compare-match a occurs (toggle output) 12.2.6 serial/timer control register (stcr) 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 0 r/w 1 icks1 0 r/w bit initial value read/write stcr is an 8-bit readable/writable register that controls register?ccess, the iic operating mode (when the on-chip iic option is included), and on-chip flash memory and also selects the tcnt input clock. for details on functions not related to the 8-bit timers, see section 3.2.4, serial/timer control register (stcr), and the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4? 2 c control (iics, iicx1, iicx0, iice): these bits control the operation of the i 2 c bus interface, etc. when the iic option is included on-chip. see section 3.2.4, serial/timer control register (stcr) and section 16, i 2 c bus interface, for details. bit 3?lash memory control register enable (flshe): controls the access of cpu to the flash memory control registers, the power-down mode control registers, and the supporting module control registers. see section 3.2.4, serial/timer control register (stcr).
343 bit 2?eserved: do not write 1 to this bit. bits 1 and 0?nternal clock select 1 and 0 (icks1, icks0): these bits, together with bits cks2 to cks0 in tcr, select the clock to be input to tcnt. for details, see section 12.2.4, timer control register. 12.2.7 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write only bit 1 is described here. for details on functions not related to the 8-bit timers, see sections 3.2.2 and 5.2.1, system control register (syscr), and the descriptions of the relevant modules. bit 1?ost interface enable (hie): controls cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers. bit 1 hie description 0 cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is enabled (initial value) 1 cpu access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers, is disabled 12.2.8 timer connection register s (tconrs) 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w bit initial value read/write tconrs is an 8-bit readable/writable register that controls access to the tmrx and tmry registers and timer connection operation. tconrs is initialized to h'00 by a reset and in hardware standby mode.
344 bit 7?mrx/tmry access select (tmrx/y): the tmrx and tmry registers can only be accessed when the hie bit in syscr is cleared to 0. some of the tmrx registers and the tmry registers are assigned to the same memory space addresses (h'fff0 to h'fff5), and the tmrx/y bit determines which registers are accessed. bit 7 accessible registers tmrx/y h'fff0 h'fff1 h'fff2 h'fff3 h'fff4 h'fff5 h'fff6 h'fff7 0 (initial value) tmrx tcrx tmrx tcsrx tmrx ticrr tmrx ticrf tmrx tcntx tmrx tcorc tmrx tcorax tmrx tcorbx 1 tmry tcry tmry tcsry tmry tcoray tmry tcorby tmry tcnty tmry tisr 12.2.9 input capture register (ticr) [tmrx additional function] 7 0 6 0 5 0 4 0 3 0 0 0 2 0 1 0 bit initial value read/write ticr is an 8-bit internal register to which the contents of tcnt are transferred on the falling edge of external reset input. the cpu cannot read or write to ticr directly. the ticr function is used in timer connection. for details, see section 13, timer connection. 12.2.10 time constant register c (tcorc) [tmrx additional function] 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write tcorc is an 8-bit readable/writable register. the sum of the contents of tcorc and ticr is continually compared with the value in tcnt. when a match is detected, a compare-match c signal is generated. note, however, that comparison is disabled during the t2 state of a tcorc write cycle and a ticr input capture cycle. tcorc is initialized to h'ff by a reset and in hardware standby mode. the tcorc function is used in timer connection. for details, see section 13, timer connection.
345 12.2.11 input capture registers r and f (ticrr, ticrf) [tmrx additional functions] 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write ticrr and ticrf are 8-bit read-only registers. when the icst bit in tconri is set to 1, ticrr and ticrf capture the contents of tcnt successively on the rise and fall of the external reset input. when one capture operation ends, the icst bit is cleared to 0. ticrr and ticrf are each initialized to h'00 by a reset and in hardware standby mode. the ticrr and ticrf functions are used in timer connection. for details, see section 12.3.6, input capture operation and section 13, timer connection. 12.2.12 timer input select register (tisr) [tmry additional function] 7 1 6 1 5 1 4 1 3 1 0 is 0 r/w 2 1 1 1 bit initial value read/write tisr is an 8-bit readable/writable register that selects the external clock/reset signal source for the counter. tisr is initialized to h'fe by a reset and in hardware standby mode. bits 7 to 1?eserved: do not write 0 to these bits. bit 0?nput select (is): selects the internal synchronization signal (ivg signal) or the timer clock/reset input pin (vsynci/tmiy (tmciy/tmriy)) as the external clock/reset signal source for the counter. bit 0 is description 0 ivg signal is selected (initial value) 1 vsynci/tmiy (tmciy/tmriy) is selected
346 12.2.13 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp12 bit or mstp8 bit is set to 1, 8-bit timer operation is halted on channels 0 and 1 or channels x and y, respectively, and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 4?odule stop (mstp12): specifies 8-bit timer (channel 0/1) module stop mode. mstpcrh bit 4 mstp12 description 0 8-bit timer (channel 0/1) module stop mode is cleared 1 8-bit timer (channel 0/1) module stop mode is set (initial value) mstpcrh bit 0?odule stop (mstp8): specifies 8-bit timer (channel x/y) and timer connection module stop mode. mstpcrh bit 0 mstp8 description 0 8-bit timer (channel x/y) and timer connection module stop mode is cleared 1 8-bit timer (channel x/y) and timer connection module stop mode is set (initial value)
347 12.3 operation 12.3.1 tcnt incrementation timing tcnt is incremented by input clock pulses (either internal or external). internal clock: an internal clock created by dividing the system clock (? can be selected by setting bits cks2 to cks0 in tcr. figure 12.2 shows the count timing. internal clock tcnt input clock tcnt n ?1 n n + 1 figure 12.2 count timing for internal clock input external clock: three incrementation methods can be selected by setting bits cks2 to cks0 in tcr: at the rising edge, the falling edge, and both rising and falling edges. note that the external clock pulse width must be at least 1.5 states for incrementation at a single edge, and at least 2.5 states for incrementation at both edges. the counter will not increment correctly if the pulse width is less than these values. figure 12.3 shows the timing of incrementation at both edges of an external clock signal.
348 external clock input pin tcnt input clock tcnt n ?1 n n + 1 figure 12.3 count timing for external clock input 12.3.2 compare-match timing setting of compare-match flags a and b (cmfa, cmfb): the cmfa and cmfb flags in tcsr are set to 1 by a compare-match signal generated when the tcor and tcnt values match. the compare-match signal is generated at the last state in which the match is true, just before the timer counter is updated. therefore, when tcor and tcnt match, the compare-match signal is not generated until the next incrementation clock input. figure 12.4 shows this timing. tcnt n n + 1 tcor n compare-match signal cmf figure 12.4 timing of cmf setting
349 timer output timing: when compare-match a or b occurs, the timer output changes as specified by the output select bits (os3 to os0) in tcsr. depending on these bits, the output can remain the same, be set to 0, be set to 1, or toggle. figure 12.5 shows the timing when the output is set to toggle at compare-match a. compare-match a signal timer output pin figure 12.5 timing of timer output timing of compare-match clear: tcnt is cleared when compare-match a or b occurs, depending on the setting of the cclr1 and cclr0 bits in tcr. figure 12.6 shows the timing of this operation. n h'00 compare-match signal tcnt figure 12.6 timing of compare-match clear
350 12.3.3 tcnt external reset timing tcnt is cleared at the rising edge of an external reset input, depending on the settings of the cclr1 and cclr0 bits in tcr. the width of the clearing pulse must be at least 1.5 states. figure 12.7 shows the timing of this operation. clear signal external reset input pin tcnt n h'00 n ?1 figure 12.7 timing of clearing by external reset input 12.3.4 timing of overflow flag (ovf) setting ovf in tcsr is set to 1 when the timer count overflows (changes from h'ff to h'00). figure 12.8 shows the timing of this operation. ovf overflow signal tcnt h'ff h'00 figure 12.8 timing of ovf setting
351 12.3.5 operation with cascaded connection if bits cks2 to cks0 in either tcr0 or tcr1 are set to b'100, the 8-bit timers of the two channels are cascaded. with this configuration, a single 16-bit timer can be used (16-bit timer mode) or compare-matches of 8-bit channel 0 can be counted by the timer of channel 1 (compare- match count mode). in this case, the timer operates as described below. 16-bit count mode: when bits cks2 to cks0 in tcr0 are set to b'100, the timer functions as a single 16-bit timer with channel 0 occupying the upper 8 bits and channel 1 occupying the lower 8 bits. ? setting of compare-match flags ? the cmf flag in tcsr0 is set to 1 when a 16-bit compare-match occurs. ? the cmf flag in tcsr1 is set to 1 when a lower 8-bit compare-match occurs. ? counter clear specification ? if the cclr1 and cclr0 bits in tcr0 have been set for counter clear at compare-match, the 16-bit counter (tcnt0 and tcnt1 together) is cleared when a 16-bit compare-match occurs. the 16-bit counter (tcnt0 and tcnt1 together) is cleared even if counter clear by the tmri0 pin has also been set. ? the settings of the cclr1 and cclr0 bits in tcr1 are ignored. the lower 8 bits cannot be cleared independently. ? pin output ? control of output from the tmo0 pin by bits os3 to os0 in tcsr0 is in accordance with the 16-bit compare-match conditions. ? control of output from the tmo1 pin by bits os3 to os0 in tcsr1 is in accordance with the lower 8-bit compare-match conditions. compare-match count mode: when bits cks2 to cks0 in tcr1 are b'100, tcnt1 counts compare-match a? for channel 0. channels 0 and 1 are controlled independently. conditions such as setting of the cmf flag, generation of interrupts, output from the tmo pin, and counter clearing are in accordance with the settings for each channel. usage note: if the 16-bit count mode and compare-match count mode are set simultaneously, the input clock pulses for tcnt0 and tcnt1 are not generated and thus the counters will stop operating. simultaneous setting of these two modes should therefore be avoided.
352 12.3.6 input capture operation tmrx has input capture registers of ticr, ticrr and ticrf. narrow pulse width can be measured with ticrr and ticrf, using capture operation controlled by the icst bit in the tconri register of the timer connection. when tmrix detects rising edge and falling edge successively after the icst bit is set to 1, the value of tcnt at the time is transferred to ticrr and ticrf, respectively. input signal to tmrix can be switched by the setting of the other bits in tconri register. (1) input capture signal input timing timing of the input capture operation is shown in figure 12.9. f tmrix input capture signal tcntx n nn m m m n + 1 n n n + 1 ticrr ticrf figure12.9 timing of input capture operation if input capture signal is input while ticrr and ticrf is read, the input capture signal delays by one system clock ( f ) period internally. figure 12.10 shows the timing of this operation.
353 f tmrix ticrr, ticrf read cycle t 1 t 2 input capture signal figure 12.10 timing of input capture signal (input capture signal is input during ticrr and ticrf read) (2) selection of the input capture signal input the input capture signal in tmrx is switched according to the setting of the bits in tconri register. input capture signal selections are shown in figure 12.11 and table 12.3. for details, see section 13.2.1, timer connection register i (tconri). tmix pin tmri1 pin tmci1 pin polarity inversion polarity inversion polarity inversion signal selector tmrix tmrx hfinv, hiinv simod1, simod0 icst figure 12.11 input capture signal selections
354 table 12.3 input capture signal selection tconri bit 4 bit 7 bit 6 bit 3 bit 1 icst simod1 simod0 hfinv hiinv description 0 input capture function not used 1 0 0 0 tmix pin input selection 1 inverted tmix pin input selection 1 0 tmri1 pin input selection 1 inverted tmri1 pin input selection 1 1 0 tmci1 pin input selection 1 inverted tmci1 pin input selection 12.4 interrupt sources the tmr0, tmr1, and tmry 8-bit timers can generate three types of interrupt: compare-match a and b (cmia and cmib), and overflow (ovi). tmrx can generate only an icix interrupt. an interrupt is requested when the corresponding interrupt enable bit is set in tcr or tcsr. independent signals are sent to the interrupt controller for each interrupt. it is also possible to activate the dtc by means of cmia and cmib interrupts from tmr0, tmr1 and tmry. an overview of 8-bit timer interrupt sources is given in tables 12.4 to 12.6. table 12.4 tmr0 and tmr1 8-bit timer interrupt sources interrupt source description dtc activation interrupt priority cmia requested by cmfa possible high cmib requested by cmfb possible ovi requested by ovf not possible low table 12.5 tmrx 8-bit timer interrupt source interrupt source description dtc activation icix requested by icf not possible
355 table 12.6 tmry 8-bit timer interrupt sources interrupt source description dtc activation interrupt priority cmia requested by cmfa possible high cmib requested by cmfb possible ovi requested by ovf not possible low 12.5 8-bit timer application example in the example below, the 8-bit timer is used to generate a pulse output with a selected duty cycle, as shown in figure 12.12. the control bits are set as follows: ? in tcr, cclr1 is cleared to 0 and cclr0 is set to 1 so that the timer counter is cleared by a tcora compare-match. ? in tcsr, bits os3 to os0 are set to b'0110, causing 1 output at a tcora compare-match and 0 output at a tcorb compare-match. with these settings, the 8-bit timer provides output of pulses at a rate determined by tcora with a pulse width determined by tcorb. no software intervention is required. tcnt h'ff counter clear tcora tcorb h'00 tmo figure 12.12 pulse output (example)
356 12.6 usage notes application programmers should note that the following kinds of contention can occur in the 8-bit timer module. 12.6.1 contention between tcnt write and clear if a timer counter clock pulse is generated during the t2 state of a tcnt write cycle, the clear takes priority, so that the counter is cleared and the write is not performed. figure 12.13 shows this operation. address tcnt address internal write signal counter clear signal tcnt n h'00 t 1 t 2 tcnt write cycle by cpu figure 12.13 contention between tcnt write and clear
357 12.6.2 contention between tcnt write and increment if a timer counter clock pulse is generated during the t2 state of a tcnt write cycle, the write takes priority and the counter is not incremented. figure 12.14 shows this operation. address tcnt address internal write signal tcnt input clock tcnt nm t 1 t 2 tcnt write cycle by cpu counter write data figure 12.14 contention between tcnt write and increment
358 12.6.3 contention between tcor write and compare-match during the t2 state of a tcor write cycle, the tcor write has priority even if a compare-match occurs and the compare-match signal is disabled. figure 12.15 shows this operation. with tmrx, an icr input capture contends with a compare-match in the same way as with a write to tcorc. in this case, the input capture has priority and the compare-match signal is inhibited. address tcor address internal write signal tcnt tcor nm t 1 t 2 tcor write cycle by cpu tcor write data n n + 1 compare-match signal inhibited figure 12.15 contention between tcor write and compare-match
359 12.6.4 contention between compare-matches a and b if compare-matches a and b occur at the same time, the 8-bit timer operates in accordance with the priorities for the output states set for compare-match a and compare-match b, as shown in table 12.7. table 12.7 timer output priorities output setting priority toggle output high 1 output 0 output no change low 12.6.5 switching of internal clocks and tcnt operation tcnt may increment erroneously when the internal clock is switched over. table 12.8 shows the relationship between the timing at which the internal clock is switched (by writing to the cks1 and cks0 bits) and the tcnt operation when the tcnt clock is generated from an internal clock, the falling edge of the internal clock pulse is detected. if clock switching causes a change from high to low level, as shown in no. 3 in table 12.8, a tcnt clock pulse is generated on the assumption that the switchover is a falling edge. this increments tcnt. erroneous incrementation can also happen when switching between internal and external clocks.
360 table 12.8 switching of internal clock and tcnt operation no. timing of switchover by means of cks1 and cks0 bits tcnt clock operation 1 switching from low to low * 1 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 2 switching from low to high * 2 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2
361 no. timing of switchover by means of cks1 and cks0 bits tcnt clock operation 3 switching from high to low * 3 clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2 * 4 4 switching from high to high clock before switchover clock after switchover tcnt clock tcnt cks bit rewrite n n + 1 n + 2 notes: 1. includes switching from low to stop, and from stop to low. 2. includes switching from stop to high. 3. includes switching from high to stop. 4. generated on the assumption that the switchover is a falling edge; tcnt is incremented.
362
363 section 13 timer connection 13.1 overview the h8s/2169 or h8s/2149 allows interconnection between a combination of input signals, the input/output of the single free-running timer (frt) channel and the three 8-bit timer channels (tmr1, tmrx, and tmry). this capability can be used to implement complex functions such as pwm decoding and clamp waveform output. all the timers are initially set for independent operation. 13.1.1 features the features of the timer connection facility are as follows. five input pins and four output pins, all of which can be designated for phase inversion. positive logic is assumed for all signals used within the timer connection facility. an edge-detection circuit is connected to the input pins, simplifying signal input detection. tmrx can be used for pwm input signal decoding and clamp waveform generation. an external clock signal divided by tmr1 can be used as the frt capture input signal. an internal synchronization signal can be generated using the frt and tmry. a signal generated/modified using an input signal and timer connection can be selected and output.
364 13.1.2 block diagram figure 13.1 shows a block diagram of the timer connection facility. edge detection edge detection vsynci/ ftia/tmiy vfbacki/ ftib ftic ftid phase inversion phase inversion phase inversion phase inversion phase inversion phase inversion ivi signal selection read flag edge detection edge detection edge detection phase inversion phase inversion phase inversion read flag ivi signal frt input selec- tion set sync res vsync modify ftia ftib ftic ftid 16-bit frt ocra +vr, +vf icrd +1m, +2m compare match ftoa cma(r) cma(f) ftob cm2m cm1m res set 2f h mask generation 2f h mask/flag cblank waveform generation tmr1 input selection tmci 8-bit tmr1 tmri cmb tmo set ivg signal ivo signal res vsync generation ivo signal selection tmiy signal selection frt output selection vsynco/ ftoa tmri/tmci tmo 8-bit tmry ihg signal cblank hsynco/ tmo1 tmox tmo1 output selection iho signal selection cl4 generation cl4 signal clampo/ ftic cl signal selection pdc signal pwm decoding 8-bit tmrx cmb tmo cma icr icr +1c compare match clamp waveform generation tmci tmri cm1c cl1 signal cl2 signal cl3 signal ihi signal ihi signal selection hsynci/ tmci1 csynci/ tmri1 hfbacki/ ftci/tmix figure 13.1 block diagram of timer connection facility
365 13.1.3 input and output pins table 13.1 lists the timer connection input and output pins. table 13.1 timer connection input and output pins name abbreviation input/ output function vertical synchronization signal input pin vsynci input vertical synchronization signal input pin or ftia input pin/tmiy input pin horizontal synchronization signal input pin hsynci input horizontal synchronization signal input pin or tmci1 input pin composite synchronization signal input pin csynci input composite synchronization signal input pin or tmri1 input pin spare vertical synchronization signal input pin vfbacki input spare vertical synchronization signal input pin or ftib input pin spare horizontal synchronization signal input pin hfbacki input spare horizontal synchronization signal input pin or ftci input pin/tmix input pin vertical synchronization signal output pin vsynco output vertical synchronization signal output pin or ftoa output pin horizontal synchronization signal output pin hsynco output horizontal synchronization signal output pin or tmo1 output pin clamp waveform output pin clampo output clamp waveform output pin or ftic input pin blanking waveform output pin cblank output blanking waveform output pin
366 13.1.4 register configuration table 13.2 lists the timer connection registers. timer connection registers can only be accessed when the hie bit in syscr is 0. table 13.2 register configuration name abbreviation r/w initial value address * 1 timer connection register i tconri r/w h'00 h'fffc timer connection register o tconro r/w h'00 h'fffd timer connection register s tconrs r/w h'00 h'fffe edge sense register sedgr r/(w) * 2 h'00 * 3 h'ffff module stop control register mstprh r/w h'3f h'ff86 mstprl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. bits 7 to 2: only 0 can be written, to clear the flags. 3. bits 1 and 0: undefined (reflect the pin states). 13.2 register descriptions 13.2.1 timer connection register i (tconri) bit initial value read/write 7 simod1 0 r/w 6 simod0 0 r/w 5 scone 0 r/w 4 icst 0 r/w 3 hfinv 0 r/w 0 viinv 0 r/w 2 vfinv 0 r/w 1 hiinv 0 r/w tconri is an 8-bit readable/writable register that controls connection between timers, the signal source for synchronization signal input, phase inversion, etc. tconr1 is initialized to h'00 by a reset and in hardware standby mode.
367 bits 7 and 6?nput synchronization mode select 1 and 0 (simod1, simod0): these bits select the signal source of the ihi and ivi signals. bit 7 bit 6 description simod1 simod0 mode ihi signal ivi signal 0 0 no signal (initial value) hfbacki input vfbacki input 1 s-on-g mode csynci input pdc input 1 0 composite mode hsynci input pdc input 1 separate mode hsynci input vsynci input bit 5?ynchronization signal connection enable (scone): selects the signal source of the frt fti input and the tmr1 tmci1/tmri1 input. bit 5 description scone mode ftia ftib ftic ftid tmci1 tmri1 0 normal connection (initial value) ftia input ftib input ftic input ftid input tmci1 input tmri1 input 1 synchronization signal connection mode ivi signal tmo1 signal vfbacki input ihi signal ihi signal ivi inverse signal bit 4?nput capture start bit (icst): the tmrx external reset input (tmrix) is connected to the ihi signal. tmrx has input capture registers (ticr, ticrr, and ticrf). ticrr and ticrf can measure the width of a short pulse by means of a single capture operation under the control of the icst bit. when a rising edge followed by a falling edge is detected on tmrix after the icst bit is set to 1, the contents of tcnt at those points are captured into ticrr and ticrf, respectively, and the icst bit is cleared to 0. bit 4 icst description 0 the ticrr and ticrf input capture functions are stopped [clearing condition] when a rising edge followed by a falling edge is detected on tmrix (initial value) 1 the ticrr and ticrf input capture functions are operating (waiting for detection of a rising edge followed by a falling edge on tmrix) [setting condition] when 1 is written in icst after reading icst = 0
368 bits 3 to 0?nput synchronization signal inversion (hfinv, vfinv, hiinv, viinv): these bits select inversion of the input phase of the spare horizontal synchronization signal (hfbacki), the spare vertical synchronization signal (vfbacki), the horizontal synchronization signal and composite synchronization signal (hsynci, csynci), and the vertical synchronization signal (vsynci). bit 3 hfinv description 0 the hfbacki pin state is used directly as the hfbacki input (initial value) 1 the hfbacki pin state is inverted before use as the hfbacki input bit 2 vfinv description 0 the vfbacki pin state is used directly as the vfbacki input (initial value) 1 the vfbacki pin state is inverted before use as the vfbacki input bit 1 hiinv description 0 the hsynci and csynci pin states are used directly as the hsynci and csynci inputs (initial value) 1 the hsynci and csynci pin states are inverted before use as the hsynci and csynci inputs bit 0 viinv description 0 the vsynci pin state is used directly as the vsynci input (initial value) 1 the vsynci pin state is inverted before use as the vsynci input
369 13.2.2 timer connection register o (tconro) bit initial value read/write 7 hoe 0 r/w 6 voe 0 r/w 5 cloe 0 r/w 4 cboe 0 r/w 3 hoinv 0 r/w 0 cboinv 0 r/w 2 voinv 0 r/w 1 cloinv 0 r/w tconro is an 8-bit readable/writable register that controls output signal output, phase inversion, etc. tconro is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 4?utput enable (hoe, voe, cloe, cboe): these bits control enabling/disabling of horizontal synchronization signal (hsynco), vertical synchronization signal (vsynco), clamp waveform (clampo), and blanking waveform (cblank) output. when output is disabled, the state of the relevant pin is determined by the port dr and ddr, frt, tmr, and pwm settings. output enabling/disabling control does not affect the port, frt, or tmr input functions, but some frt and tmr input signal sources are determined by the scone bit in tconri. bit 7 hoe description 0 the p44/tmo1/hirq1/hsynco pin functions as the p44/tmo1/ hirq1 pin (initial value) 1 the p44/tmo1/hirq1/hsynco pin functions as the hsynco pin bit 6 voe description 0 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the p61/ftoa/ kin1 /cin1 pin (initial value) 1 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the vsynco pin bit 5 cloe description 0 the p64/ftic/ kin4 /cin4/clampo pin functions as the p64/ftic/ kin4 /cin4 pin (initial value) 1 the p64/ftic/ kin4 /cin4/clampo pin functions as the clampo pin
370 bit 4 cboe description 0 the p27/a15/pw15/cblank pin functions as the p27/a15/pw15 pin (initial value) 1 in mode 1 (expanded mode with on-chip rom disabled): the p27/a15/pw15/cblank pin functions as the a15 pin in modes 2 and 3 (modes with on-chip rom enabled): the p27/a15/pw15/cblank pin functions as the cblank pin bits 3 to 0?utput synchronization signal inversion (hoinv, voinv, cloinv, cboinv): these bits select inversion of the output phase of the horizontal synchronization signal (hsynco), the vertical synchronization signal (vsynco), the clamp waveform (clampo), and the blank waveform (cblank). bit 3 hoinv description 0 the iho signal is used directly as the hsynco output (initial value) 1 the iho signal is inverted before use as the hsynco output bit 2 voinv description 0 the ivo signal is used directly as the vsynco output (initial value) 1 the ivo signal is inverted before use as the vsynco output bit 1 cloinv description 0 the clo signal (cl1, cl2, cl3, or cl4 signal) is used directly as the clampo output (initial value) 1 the clo signal (cl1, cl2, cl3, or cl4 signal) is inverted before use as the clampo output bit 0 cboinv description 0 the cblank signal is used directly as the cblank output (initial value) 1 the cblank signal is inverted before use as the cblank output
371 13.2.3 timer connection register s (tconrs) bit initial value read/write 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w tconrs is an 8-bit readable/writable register that selects 8-bit timer tmrx/tmry access and the synchronization signal output signal source and generation method. tconrs is initialized to h'00 by a reset and in hardware standby mode. bit 7?mrx/tmry access select (tmrx/y): the tmrx and tmry registers can only be accessed when the hie bit in syscr is cleared to 0. some of the tmrx registers and the tmry registers are assigned to the same memory space addresses (h'fff0 to h'fff5), and the tmrx/y bit determines which registers are accessed. bit 7 tmrx/y description 0 the tmrx registers are accessed at addresses h'fff0 to h'fff5 (initial value) 1 the tmry registers are accessed at addresses h'fff0 to h'fff5 bit 6?nternal synchronization signal select (isgene): selects internal synchronization signals (ihg, ivg, and cl4 signals) as the signal sources for the iho, ivo, and clo signals. bits 5 and 4?orizontal synchronization output mode select 1 and 0 (homod1, homod0): these bits select the signal source and generation method for the iho signal. bit 6 bit 5 bit 4 isgene vomod1 vomod0 description 0 0 0 the ihi signal (without 2fh modification) is selected (initial value) 1 the ihi signal (with 2fh modification) is selected 1 0 the cl1 signal is selected 1 1 0 0 the ihg signal is selected 1 10 1
372 bits 3 and 2?ertical synchronization output mode select 1 and 0 (vomod1, vomod0): these bits select the signal source and generation method for the ivo signal. bit 6 bit 3 bit 2 isgene vomod1 vomod0 description 0 0 0 the ivi signal (without fall modification or ihi synchronization) is selected (initial value) 1 the ivi signal (without fall modification, with ihi synchronization) is selected 1 0 the ivi signal (with fall modification, without ihi synchronization) is selected 1 the ivi signal (with fall modification and ihi synchronization) is selected 1 0 0 the ivg signal is selected 1 10 1 bits 1 and 0?lamp waveform mode select 1 and 0 (clmod1, clmod0): these bits select the signal source for the clo signal (clamp waveform). bit 6 bit 1 bit 0 isgene clmod1 clmod2 description 0 0 0 the cl1 signal is selected (initial value) 1 the cl2 signal is selected 1 0 the cl3 signal is selected 1 1 0 0 the cl4 signal is selected 1 10 1
373 13.2.4 edge sense register (sedgr) bit initial value read/write notes: 1. only 0 can be written, to clear the flags. 2. the initial value is undefined since it depends on the pin states. 7 vedg 0 r/(w) 6 hedg 0 r/(w) 5 cedg 0 r/(w) 4 hfedg 0 r/(w) 3 vfedg 0 r/(w) 0 ivi * 2 r 2 preqf 0 r/(w) 1 ihi * 2 r * 1 * 1 * 1 * 1 * 1 * 1 sedgr is an 8-bit readable/writable register used to detect a rising edge on the timer connection input pins and the occurrence of 2fh modification, and to determine the phase of the ivi and ihi signals. the upper 6 bits of sedgr are initialized to 0 by a reset and in hardware standby mode. the initial value of the lower 2 bits is undefined, since it depends on the pin states. bit 7?synci edge (vedg): detects a rising edge on the vsynci pin. bit 7 vedg description 0 [clearing condition] when 0 is written in vedg after reading vedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the vsynci pin bit 6?synci edge (hedg): detects a rising edge on the hsynci pin. bit 6 hedg description 0 [clearing condition] when 0 is written in hedg after reading hedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the hsynci pin
374 bit 5?synci edge (cedg): detects a rising edge on the csynci pin. bit 5 cedg description 0 [clearing condition] when 0 is written in cedg after reading cedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the csynci pin bit 4?fbacki edge (hfedg): detects a rising edge on the hfbacki pin. bit 4 hfedg description 0 [clearing condition] when 0 is written in hfedg after reading hfedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the hfbacki pin bit 3?fbacki edge (vfedg): detects a rising edge on the vfbacki pin. bit 3 vfedg description 0 [clearing condition] when 0 is written in vfedg after reading vfedg = 1 (initial value) 1 [setting condition] when a rising edge is detected on the vfbacki pin bit 2?re-equalization flag (preqf): detects the occurrence of an ihi signal 2fh modification condition. the generation of a falling/rising edge in the ihi signal during a mask interval is expressed as the occurrence of a 2fh modification condition. for details, see section 13.3.4, ihi signal 2fh modification. bit 2 preqf description 0 [clearing condition] when 0 is written in preqf after reading preqf = 1 (initial value) 1 [setting condition] when an ihi signal 2fh modification condition is detected
375 bit 1?hi signal level (ihi): indicates the current level of the ihi signal. signal source and phase inversion selection for the ihi signal depends on the contents of tconri. read this bit to determine whether the input signal is positive or negative, then maintain the ihi signal at positive phase by modifying tconri. bit 1 ihi description 0 the ihi signal is low 1 the ihi signal is high bit 0?vi signal level (ivi): indicates the current level of the ivi signal. signal source and phase inversion selection for the ivi signal depends on the contents of tconri. read this bit to determine whether the input signal is positive or negative, then maintain the ivi signal at positive phase by modifying tconri. bit 0 ivi description 0 the ivi signal is low 1 the ivi signal is high 13.2.5 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp13, mstp12, and mstp8 bits are set to 1, the 16-bit free-running timer, 8-bit timer channels 0 and 1, and 8-bit timer channels x and y and timer connection, respectively, halt and enter module stop mode. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode.
376 mstpcrh bit 5?odule stop (mstp13): specifies frt module stop mode. mstpcrh bit 5 mstp13 description 0 frt module stop mode is cleared 1 frt module stop mode is set (initial value) mstpcrh bit 4?odule stop (mstp12): specifies 8-bit timer channel 0 and 1 module stop mode. mstpcrh bit 4 mstp12 description 0 8-bit timer channel 0 and 1 module stop mode is cleared 1 8-bit timer channel 0 and 1 module stop mode is set (initial value) mstpcrh bit 0?odule stop (mstp8): specifies 8-bit timer channel x and y and timer connection module stop mode. mstpcrh bit 0 mstp8 description 0 8-bit timer channel x and y and timer connection module stop mode is cleared 1 8-bit timer channel x and y and timer connection module stop mode is set (initial value) 13.3 operation 13.3.1 pwm decoding (pdc signal generation) the timer connection facility and tmrx can be used to decode a pwm signal in which 0 and 1 are represented by the pulse width. to do this, a signal in which a rising edge is generated at regular intervals must be selected as the ihi signal. the timer counter (tcnt) in tmrx is set to count the internal clock pulses and to be cleared on the rising edge of the external reset signal (ihi signal). the value to be used as the threshold for deciding the pulse width is written in tcorb. the pwm decoder contains a delay latch which uses the ihi signal as data and compare-match signal b (cmb) as a clock, and the state of the ihi signal (the result of the pulse width decision) at the compare-match signal b timing after tcnt is
377 reset by the rise of the ihi signal is output as the pdc signal. the pulse width setting using ticrr and ticrf of tmrx can be used to determine the pulse width decision threshold. examples of tcr and tcorb settings are shown in tables 13.3 and 13.4, and the timing chart is shown in figure 13.2. table 13.3 examples of tcr settings bit(s) abbreviation contents description 7 6 5 cmieb cmiea ovie 0 0 0 interrupts due to compare-match and overflow are disabled 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (ihi signal) 2 to 0 cks2 to cks0 001 incremented on internal clock: table 13.4 examples of tcorb (pulse width threshold) settings ?10 mhz h'07 0.8 m s h'0f 1.6 m s h'1f 3.2 m s h'3f 6.4 m s h'7f 12.8 m s ihi signal ihi signal is tested at compare-match counter reset caused by ihi signal counter clear caused by tcnt overflow at the 2nd compare-match, ihi signal is not tested pdc signal tcnt tcorb (threshold) figure 13.2 timing chart for pwm decoding
378 13.3.2 clamp waveform generation (cl1/cl2/cl3 signal generation) the timer connection facility and tmrx can be used to generate signals with different duty cycles and rising/falling edges (clamp waveforms) in synchronization with the input signal (ihi signal). three clamp waveforms can be generated: the cl1, cl2, and cl3 signals. in addition, the cl4 signal can be generated using tmry. the cl1 signal rises simultaneously with the rise of the ihi signal, and when the cl1 signal is high, the cl2 signal rises simultaneously with the fall of the ihi signal. the fall of both the cl1 and the cl2 signal can be specified by tcora. the rise of the cl3 signal can be specified as simultaneous with the sampling of the fall of the ihi signal using the system clock, and the fall of the cl3 signal can be specified by tcorc. tcnt in tmrx is set to count internal clock pulses and to be cleared on the rising edge of the external reset signal (ihi signal). the cl3 signal can also fall when the ihi signal rises. the value to be used as the cl1 signal pulse width is written in tcora. write a value of h'02 or more in tcora when internal clock ?is selected as the tmrx counter clock, and a value or h'01 or more when ?2 is selected. when internal clock ?is selected, the cl1 signal pulse width is (tcora set value + 3 0.5). when the cl2 signal is used, the setting must be made so that this pulse width is greater than the ihi signal pulse width. the value to be used as the cl3 signal pulse width is written in tcorc. the ticr register in tmrx captures the value of tcnt at the inverse of the external reset signal edge (in this case, the falling edge of the ihi signal). the timing of the fall of the cl3 signal is determined by the sum of the contents of ticr and tcorc. caution is required if the rising edge of the ihi signal precedes the fall timing set by the contents of tcorc, since the ihi signal will cause the cl3 signal to fall. examples of tmrx tcr settings are the same as those in table 13.3. the clamp waveform timing charts are shown in figures 13.3 and 13.4. since the rise of the cl1 and cl2 signals is synchronized with the edge of the ihi signal, and their fall is synchronized with the system clock, the pulse width variation is equivalent to the resolution of the system clock. both the rise and the fall of the cl3 signal are synchronized with the system clock and the pulse width is fixed, but there is a variation in the phase relationship with the ihi signal equivalent to the resolution of the system clock.
379 ihi signal cl1 signal cl2 signal tcnt tcora figure 13.3 timing chart for clamp waveform generation (cl1 and cl2 signals) ihi signal cl3 signal tcnt ticr+tcorc ticr figure 13.4 timing chart for clamp waveform generation (cl3 signal) 13.3.3 measurement of 8-bit timer divided waveform period the timer connection facility, tmr1, and the free-running timer (frt) can be used to measure the period of an ihi signal divided waveform. since tmr1 can be cleared by a rising edge of the external reset signal (inverse of the ivi signal), the rise and fall of the ihi signal divided waveform can be virtually synchronized with the ivi signal. this enables period measurement to be carried out efficiently. to measure the period of an ihi signal divided waveform, tcnt in tmr1 is set to count the external clock (ihi signal) pulses and to be cleared on the rising edge of the external reset signal (inverse of the ivi signal). the value to be used as the division factor is written in tcora, and the tmo output method is specified by the os bits in tcsr. examples of tcr and tcsr settings are shown in table 13.5, and the timing chart for measurement of the ivi signal and ihi signal divided waveform periods is shown in figure 13.5. the period of the ihi signal divided waveform is given by (icrd(3) ?icrd(2)) the resolution.
380 table 13.5 examples of tcr and tcsr settings register bit(s) abbreviation contents description tcr in tmr1 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (inverse of the ivi signal) 2 to 0 cks2 to cks0 101 tcnt is incremented on the rising edge of the external clock (ihi signal) tcsr in tmr1 3 to 0 os3 to os0 0011 not changed by compare-match b; output inverted by compare-match a (toggle output): division by 512 1001 or when tcorb < tcora, 1 output on compare-match b, and 0 output on compare-match a: division by 256 tcr in frt 6 iedgb 0/1 0: frc value is transferred to icrb on falling edge of input capture input b (ihi divided signal waveform) 1: frc value is transferred to icrb on rising edge of input capture input b (ihi divided signal waveform) 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?8 tcsr in frt 0 cclra 0 frc clearing is disabled
381 ivi signal ihi signal divided waveform frc icrb icrb(1) icrb(2) icrb(3) icrb(4) figure 13.5 timing chart for measurement of ivi signal and ihi signal divided waveform periods 13.3.4 ihi signal and 2fh modification by using the timer connection frt, even if there is a part of the ihi signal with twice the frequency, this can be eliminated. in order for this function to operate properly, the duty cycle of the ihi signal must be approximately 30% or less, or approximately 70% or above. the 8-bit ocrdm contents or twice the ocrdm contents can be added automatically to the data captured in icrd in the frt, and compare-matches generated at these points. the interval between the two compare-matches is called a mask interval. a value equivalent to approximately 1/3 the ihi signal period is written in ocrdm. icrd is set so that capture is performed on the rise of the ihi signal. since the ihi signal supplied to the iho signal selection circuit is normally set on the rise of the ihi signal and reset on the fall, its waveform is the same as that of the original ihi signal. when 2fh modification is selected, ihi signal edge detection is disabled during mask intervals. capture is also disabled during these intervals. examples of frt tcr settings are shown in table 13.6, and the 2fh modification timing chart is shown in figure 13.6.
382 table 13.6 examples of tcr, tcsr, tcor, and ocrdm settings register bit(s) abbreviation contents description tcr in frt 4 iedgd 1 frc value is transferred to icrd on the rising edge of input capture input d (ihi signal) 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?8 tcsr in frt 0 cclra 0 frc clearing is disabled tcor in frt 7 icrdms 1 icrd is set to the operating mode in which ocrdm is used ocrdm in frt 7 to 0 ocrdm7 to 0 h'01 to h'ff specifies the period during which icrd operation is masked ihi signal (without 2fh modification) ihi signal (with 2fh modification) mask interval icrd + ocrdm 2 icrd + ocrdm frc icrd figure 13.6 2fh modification timing chart
383 13.3.5 ivi signal fall modification and ihi synchronization by using the timer connection tmr1, the fall of the ivi signal can be shifted backward by the specified number of ihi signal waveforms. also, the fall of the ivi signal can be synchronized with the rise of the ihi signal. to perform 8-bit timer divided waveform period measurement, tcnt in tmr1 is set to count external clock (ihi signal) pulses, and to be cleared on the rising edge of the external reset signal (inverse of the ivi signal). the number of ihi signal pulses until the fall of the ivi signal is written in tcorb. since the ivi signal supplied to the ivo signal selection circuit is normally set on the rise of the ivi signal and reset on the fall, its waveform is the same as that of the original ivi signal. when fall modification is selected, a reset is performed on a tmr1 tcorb compare-match. the fall of the waveform generated in this way can be synchronized with the rise of the ihi signal, regardless of whether or not fall modification is selected. examples of tmr1 tcorb, tcr, and tcsr settings are shown in table 13.7, and the fall modification/ihi synchronization timing chart is shown in figure 13.7. table 13.7 examples of tcorb, tcr, and tcsr settings register bit(s) abbreviation contents description tcr in tmr1 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 11 tcnt is cleared by the rising edge of the external reset signal (inverse of the ivi signal) 2 to 0 cks2 to cks0 101 tcnt is incremented on the rising edge of the external clock (ihi signal) tcsr in tmr1 3 to 0 os3 to os0 0011 not changed by compare-match b; output inverted by compare-match a (toggle output) 1001 or when tcorb tcora, 1 output on compare-match b, 0 output on compare- match a tcorb in tmr1 h'03 (example) compare-match on the 4th (example) rise of the ihi signal after the rise of the inverse of the ivi signal
384 0 1 2 3 4 5 tcnt tcnt = tcorb (3) ihi signal ivi signal (pdc signal) ivo signal (without fall modification, with ihi synchronization) ivo signal (with fall modification, without ihi synchronization) ivo signal (with fall modification and ihi synchronization) figure 13.7 fall modification/ihi synchronization timing chart 13.3.6 internal synchronization signal generation (ihg/ivg/cl4 signal generation) by using the timer connection frt and tmry, it is possible to automatically generate internal signals (ihg and ivg signals) corresponding to the ihi and ivi signals. as the ihg signal is synchronized with the rise of the ivg signal, the ihg signal period must be made a divisor of the ivg signal period in order to keep it constant. in addition, the cl4 signal can be generated in synchronization with the ihg signal. the contents of ocra in the frt are updated by the automatic addition of the contents of ocrar or ocraf, alternately, each time a compare-match occurs. a value corresponding to the 0 interval of the ivg signal is written in ocrar, and a value corresponding to the 1 interval of the ivg signal is written in ocraf. the ivg signal is set by a compare-match after an ocrar addition, and reset by a compare-match after an ocraf addition. the ihg signal is the tmry 8-bit timer output. tmry is set to count internal clock pulses, and to be cleared on tcora compare-match, to fix the period and set the timer output. tcorb is set so as to reset the timer output. the ivg signal is connected as the tmry reset input (tmri), and the rise of the ivg signal can be treated in the same way as a tcora compare-match. the cl4 signal is a waveform that rises within one system clock period after the fall of the ihg signal, and has a 1 interval of 6 system clock periods. examples of settings of tcora, tcorb, tcr, and tcsr in tmry, and ocrar, ocraf, and tcr in the frt, are shown in table 13.8, and the ihg signal/ivg signal timing chart is shown in figure 13.8.
385 table 13.8 examples of ocrar, ocraf, tocr, tcora, tcorb, tcr, and tcsr settings register bit(s) abbreviation contents description tcr in tmry 7 cmieb 0 interrupts due to compare-match and overflow are disabled 6 cmiea 0 5 ovie 0 4 and 3 cclr1, cclr0 01 tcnt is cleared by compare-match a 2 to 0 cks2 to cks0 001 tcnt is incremented on internal clock: ?4 tcsr in tmry 3 to 0 os3 to os0 0110 0 output on compare-match b 1 output on compare-match a tocra in tmry h'3f (example) ihg signal period = ? 256 tocrb in tmry h'03 (example) ihg signal 1 interval = ? 16 tcr in frt 1 and 0 cks1, cks0 01 frc is incremented on internal clock: ?8 ocrar in frt h'7fef (example) ivg signal 0 interval = ? 262016 ivg signal period = ? 262144 (1024 times ihg signal) ocraf in frt h'000f (example) ivg signal 1 interval = ? 128 tocr in frt 6 ocrams 1 ocra is set to the operating mode in which ocrar and ocraf are used
386 6 system clocks 6 system clocks 6 system clocks ocra (4) = ocra (3) + ocrar ocra (3) = ocra (2) + ocraf ocra (2) = ocra (1) + ocrar ocra (1) = ocra (0) + ocraf ocra frc cl4 signal ihg signal tcora tcorb tcnt ivg signal figure 13.8 ivg signal/ihg signal/cl4 signal timing chart
387 13.3.7 hsynco output with the hsynco output, the meaning of the signal source to be selected and use or non-use of modification varies according to the ihi signal source and the waveform required by external circuitry. the meaning of the hsynco output in each mode is shown in table 13.9. table 13.9 meaning of hsynco output in each mode mode ihi signal iho signal meaning of iho signal no signal hfbacki input ihi signal (without 2fh modification) hfbacki input is output directly ihi signal (with 2fh modification) meaningless unless there is a double-frequency part in the hfbacki input cl1 signal hfbacki input 1 interval is changed before output ihg signal internal synchronization signal is output s-on-g mode csynci input ihi signal (without 2fh modification) csynci input (composite synchronization signal) is output directly ihi signal (with 2fh modification) double-frequency part of csynci input (composite synchronization signal) is eliminated before output cl1 signal csynci input (composite synchronization signal) horizontal synchronization signal part is separated before output ihg signal internal synchronization signal is output composite mode hsynci input ihi signal (without 2fh modification) hsynci input (composite synchronization signal) is output directly ihi signal (with 2fh modification) double-frequency part of hsynci input (composite synchronization signal) is eliminated before output cl1 signal hsynci input (composite synchronization signal) horizontal synchronization signal part is separated before output ihg signal internal synchronization signal is output separate mode hsynci input ihi signal (without 2fh modification) hsynci input (horizontal synchronization signal) is output directly ihi signal (with 2fh modification) meaningless unless there is a double-frequency part in the hsynci input (horizontal synchronization signal) cl1 signal hsynci input (horizontal synchronization signal) 1 interval is changed before output ihg signal internal synchronization signal is output
388 13.3.8 vsynco output with the vsynco output, the meaning of the signal source to be selected and use or non-use of modification varies according to the ivi signal source and the waveform required by external circuitry. the meaning of the vsynco output in each mode is shown in table 13.10. table 13.10 meaning of vsynco output in each mode mode ivi signal ivo signal meaning of ivo signal no signal vfbacki input ivi signal (without fall modification or ihi synchronization) vfbacki input is output directly ivi signal (without fall modification, with ihi synchronization) meaningless unless vfbacki input is synchronized with hfbacki input ivi signal (with fall modification, without ihi synchronization) vfbacki input fall is modified before output ivi signal (with fall modification and ihi synchronization) vfbacki input fall is modified and signal is synchronized with hfbacki input before output ivg signal internal synchronization signal is output s-on-g mode or composite mode pdc signal ivi signal (without fall modification or ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated before output ivi signal (without fall modification, with ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, and signal is synchronized with csynci/hsynci input before output ivi signal (with fall modification, without ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, and fall is modified before output ivi signal (with fall modification and ihi synchronization) csynci/hsynci input (composite synchronization signal) vertical synchronization signal part is separated, fall is modified, and signal is synchronized with csynci/hsynci input before output ivg signal internal synchronization signal is output
389 mode ivi signal ivo signal meaning of ivo signal separate mode vsynci input ivi signal (without fall modification or ihi synchronization) vsynci input (vertical synchronization signal) is output directly ivi signal (without fall modification, with ihi synchronization) meaningless unless vsynci input (vertical synchronization signal) is synchronized with hsynci input (horizontal synchronization signal) ivi signal (with fall modification, without ihi synchronization) vsynci input (vertical synchronization signal) fall is modified before output ivi signal (with fall modification and ihi synchronization) vsynci input (vertical synchronization signal) fall is modified and signal is synchronized with hsynci input (horizontal synchronization signal) before output ivg signal internal synchronization signal is output 13.3.9 cblank output using the signals generated/selected with timer connection, it is possible to generate a waveform based on the composite synchronization signal (blanking waveform). one kind of blanking waveform is generated by combining hfbacki and vfbacki inputs, with the phase polarity made positive by means of bits hfinv and vfinv in tconri, with the ivo signal. the composition logic is shown in figure 13.9. reset set cblank signal (positive) hfbacki input (positive) vfbacki input (positive) ivo signal (positive) q falling edge sensing rising edge sensing figure 13.9 cblank output waveform generation
390
391 section 14 watchdog timer (wdt) 14.1 overview the h8s/2169 or h8s/2149 has an on-chip watchdog timer with two channels (wdt0, wdt1) for monitoring system operation. the wdt outputs an overflow signal ( reso ) if a system crash prevents the cpu from writing to the timer counter, allowing it to overflow. at the same time, the wdt can also generate an internal reset signal or internal nmi interrupt signal. when this watchdog function is not needed, the wdt can be used as an interval timer. in interval timer mode, an interval timer interrupt is generated each time the counter overflows. 14.1.1 features wdt features are listed below. ? switchable between watchdog timer mode and interval timer mode ? internal reset or internal interrupt generated when the timer counter overflows ? wovi interrupt generation in interval timer mode ? choice of internal reset or nmi interrupt generation in watchdog timer mode ? reso output in watchdog timer mode ? in watchdog timer mode, a low-level signal is output from the reso pin when the counter overflows (when internal reset is selected) ? choice of 8 (wdt0) or 16 (wdt1) counter input clocks ? maximum wdt interval: system clock period 131072 256 ? subclock can be selected for the wdt1 input counter maximum interval when the subclock is selected: subclock period 256 256
392 14.1.2 block diagram figures 14.1 (a) and (b) show block diagrams of wdt0 and wdt1. overflow wovi0 (interrupt request signal) internal reset signal * 1 reso signal * 1 tcnt tcsr ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 clock clock select internal clock source bus interface module bus internal bus wdt0 legend: tcsr: timer control/status register tcnt: timer counter internal nmi interrupt request signal * 2 interrupt control reset control notes: 1. reso pin output goes low when the internal reset signal is generated by overflow of tcnt in either wdt0 or wdt1. the reset of the wdt that overflowed first takes precedence over the internal reset signal. 2. the internal nmi interrupt request signal can be output independently by either wdt0 or wdt1. the interrupt controller does not distinguish between nmi interrupt requests from wdt0 and wdt1. figure 14.1 (a) block diagram of wdt0
393 overflow tcnt tcsr ?2 ?64 ?128 ?512 ?2048 ?8192 ?32768 ?131072 clock clock select interrupt control reset control internal clock source bus interface module bus internal bus wdt1 wovi1 (interrupt request signal) internal reset signal * 1 internal nmi (interrupt request signal) * 2 legend: tcsr: timer control/status register tcnt: timer counter sub /2 sub /4 sub /8 sub /16 sub /32 sub /64 sub /128 sub /256 reso signal * 1 notes: 1. reso pin output goes low when the internal reset signal is generated by overflow of tcnt in either wdt0 or wdt1. the reset of the wdt that overflowed first takes precedence over the internal reset signal. 2. the internal nmi interrupt request signal can be output independently by either wdt0 or wdt1. the interrupt controller does not distinguish between nmi interrupt requests from wdt0 and wdt1. figure 14.1 (b) block diagram of wdt1 14.1.3 pin configuration table 14.1 describes the wdt input pin. table 14.1 wdt pin name symbol i/o function reset output pin reso output watchdog timer mode counter overflow signal output external subclock input pin excl input wdt1 prescaler counter input clock
394 14.1.4 register configuration the wdt has four registers, as summarized in table 14.2. these registers control clock selection, wdt mode switching, the reset signal, etc. table 14.2 wdt registers address * 1 channel name abbreviation r/w initial value write * 2 read 0 timer control/status register 0 tcsr0 r/(w) * 3 h'00 h'ffa8 h'ffa8 timer counter 0 tcnt0 r/w h'00 h'ffa8 h'ffa9 1 timer control/status register 1 tcsr1 r/(w) * 3 h'00 h'ffea h'ffea timer counter 1 tcnt1 r/w h'00 h'ffea h'ffeb common system control register syscr r/w h'09 h'ffc4 h'ffc4 notes: 1. lower 16 bits of the address. 2. for details of write operations, see section 14.2.4, notes on register access. 3. only 0 can be written in bit 7, to clear the flag. 14.2 register descriptions 14.2.1 timer counter (tcnt) 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write tcnt is an 8-bit readable/writable* up-counter. when the tme bit is set to 1 in tcsr, tcnt starts counting pulses generated from the internal clock source selected by bits cks2 to cks0 in tcsr. when the count overflows (changes from h'ff to h'00), the ovf flag in tcsr is set to 1. watchdog timer overflow signal ( reso ) output, an internal reset, nmi interrupt, interval timer interrupt (wovi), etc., can be generated, depending on the mode selected by the wt/ it bit and rst/ nmi bit. tcnt is initialized to h'00 by a reset, in hardware standby mode, or when the tme bit is cleared to 0. it is not initialized in software standby mode.
395 note: * tcnt is write-protected by a password to prevent accidental overwriting. for details see section 14.2.4, notes on register access. 14.2.2 timer control/status register (tcsr) ? tcsr0 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 rsts 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write note: * only 0 can be written, to clear the flag. ? tcsr1 bit initial value read/write note: * only 0 can be written, to clear the flag. 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w tcsr is an 8-bit readable/writable* register. its functions include selecting the clock source to be input to tcnt, and the timer mode. tcsr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. note: * tcsr is write-protected by a password to prevent accidental overwriting. for details see section 14.2.4, notes on register access.
396 bit 7?overflow flag (ovf): a status flag that indicates that tcnt has overflowed from h'ff to h'00. bit 7 ovf description 0 [clearing conditions] ? write 0 in the tme bit ? read tcsr when ovf = 1 * , then write 0 in ovf (initial value) 1 [setting condition] when tcnt overflows (changes from h'ff to h'00) (when internal reset request generation is selected in watchdog timer mode, ovf is cleared automatically by the internal reset.) note: when ovf flag is polled and the interval timer interrupt is disabled, ovf=1 must be read at last twice. bit 6?imer mode select (wt/ it ): selects whether the wdt is used as a watchdog timer or interval timer. if used as an interval timer, the wdt generates an interval timer interrupt request (wovi) when tcnt overflows. if used as a watchdog timer, the wdt generates a reset or nmi interrupt when tcnt overflows. when internal reset is selected in watchdog timer mode, a low- level signal is output from the reso pin. bit 6 wt/ it description 0 interval timer mode: sends the cpu an interval timer interrupt request (wovi) when tcnt overflows (initial value) 1 watchdog timer mode: generates a reset or nmi interrupt when tcnt overflows at the same time, a low-level signal is output from the reso pin (when internal reset is selected) bit 5?timer enable (tme): selects whether tcnt runs or is halted. bit 5 tme description 0 tcnt is initialized to h'00 and halted (initial value) 1 tcnt counts
397 tcsr0 bit 4?reset select (rsts): reserved. this bit should not be set to 1. tcsr1 bit 4?rescaler select (pss): selects the input clock source for tcnt in wdt1. for details, see the description of the cks2 to cks0 bits below. bit 4 pss description 0 tcnt counts ?based prescaler (psm) divided clock pulses (initial value) 1 tcnt counts ?ub-based prescaler (pss) divided clock pulses bit 3?eset or nmi (rst/ nmi ): specifies whether an internal reset or nmi interrupt is requested on tcnt overflow in watchdog timer mode. bit 3 rst/ nmi description 0 an nmi interrupt is requested (initial value) 1 an internal reset is requested
398 bits 2 to 0?clock select 2 to 0 (cks2 to cks0): these bits select an internal clock source, obtained by dividing the system clock (?, or subclock (?ub) for input to tcnt. ? wdt0 input clock selection bit 2 bit 1 bit 0 description cks2 cks1 cks0 clock overflow period * (when ?= 10 mhz) 0 0 0 ?2 (initial value) 51.2 m s 1 ?64 1.6 ms 1 0 ?128 3.2 ms 1 ?512 13.1 ms 1 0 0 ?2048 52.4 ms 1 ?8192 209.7 ms 1 0 ?32768 838.9 ms 1 ?131072 3.36 s note: * the overflow period is the time from when tcnt starts counting up from h'00 until overflow occurs.
399 wdt1 input clock selection bit 4 bit 2 bit 1 bit 0 description pss cks2 cks1 cks0 clock overflow period * (when ?= 10 mhz and sub = 32.768 khz) 0000 ?2 (initial value) 51.2 m s 1 ?64 1.6 ms 1 0 ?128 3.2 ms 1 ?512 13.1 ms 1 0 0 ?2048 52.4 ms 1 ?8192 209.7 ms 1 0 ?32768 838.9 ms 1 ?131072 3.36 s 1000 ?ub/2 15.6 ms 1 ?ub/4 31.3 ms 1 0 ?ub/8 62.5 ms 1 ?ub/16 125 ms 1 0 0 ?ub/32 250 ms 1 ?ub/64 500 ms 1 0 ?ub/128 1 s 1 ?ub/256 2 s note: * the overflow period is the time from when tcnt starts counting up from h'00 until overflow occurs. 14.2.3 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write only bit 3 is described here. for details on functions not related to the watchdog timer, see sections 3.2.2 and 5.2.1, system control register (syscr), and the descriptions of the relevant modules.
400 bit 3?external reset (xrst): indicates the reset source. when the watchdog timer is used, a reset can be generated by watchdog timer overflow in addition to external reset input. xrst is a read-only bit. it is set to 1 by an external reset, and when the rst/ nmi bit is 1, is cleared to 0 by an internal reset due to watchdog timer overflow. bit 3 xrst description 0 reset is generated by watchdog timer overflow 1 reset is generated by external reset input (initial value) 14.2.4 notes on register access the watchdog timer? tcnt and tcsr registers differ from other registers in being more difficult to write to. the procedures for writing to and reading these registers are given below. writing to tcnt and tcsr (example of wdt0): these registers must be written to by a word transfer instruction. they cannot be written to with byte transfer instructions. figure 14.2 shows the format of data written to tcnt and tcsr. tcnt and tcsr both have the same write address. for a write to tcnt, the upper byte of the written word must contain h'5a and the lower byte must contain the write data. for a write to tcsr, the upper byte of the written word must contain h'a5 and the lower byte must contain the write data. this transfers the write data from the lower byte to tcnt or tcsr. tcnt write tcsr write address: h'ffa8 address: h'ffa8 h'5a write data 15 8 7 0 h'a5 write data 15 8 7 0 figure 14.2 format of data written to tcnt and tcsr (example of wdt0) reading tcnt and tcsr (example of wdt0): these registers are read in the same way as other registers. the read addresses are h'ffa8 for tcsr, and h'ffa9 for tcnt.
401 14.3 operation 14.3.1 watchdog timer operation to use the wdt as a watchdog timer, set the wt/ it and tme bits in tcsr to 1. software must prevent tcnt overflows by rewriting the tcnt value (normally by writing h'00) before overflow occurs. this ensures that tcnt does not overflow while the system is operating normally. if tcnt overflows without being rewritten because of a system crash or other error, an internal reset or nmi interrupt request is generated. when the rst/ nmi bit is set to 1, the chip is reset for 518 system clock periods (518 ? by a counter overflow, and at the same time a low-level signal is output from the reso pin for 132 states. this is illustrated in figure 14.3. the system can be reset using this reso signal. when the rst/ nmi bit cleared to 0, an nmi interrupt request is generated by a counter overflow. in this case, the reso output signal remains high. an internal reset request from the watchdog timer and reset input from the res pin are handled via the same vector. the reset source can be identified from the value of the xrst bit in syscr. if a reset caused by an input signal from the res pin and a reset caused by wdt overflow occur simultaneously, the res pin reset has priority, and the xrst bit in syscr is set to 1. an nmi interrupt request from the watchdog timer and an interrupt request from the nmi pin are handled via the same vector. simultaneous handling of a watchdog timer nmi interrupt request and an nmi pin interrupt request must therefore be avoided.
402 tcnt value h'00 time h'ff wt/ it = 1 tme = 1 h'00 written to tcnt wt/ it = 1 tme = 1 h'00 written to tcnt 518 system clock periods internal reset signal overflow reso and internal reset generated ovf = 1 * reso signal wt/ it : timer mode select bit tme: timer enable bit ovf: overflow flag note: * cleared to 0 by an internal reset when ovf is set to 1. xrst is cleared to 0. 132 system clock periods figure 14.3 operation in watchdog timer mode (rst/ nmi = 1) 14.3.2 interval timer operation to use the wdt as an interval timer, clear the wt/ it bit in tcsr to 0 and set the tme bit to 1. an interval timer interrupt (wovi) is generated each time tcnt overflows, provided that the wdt is operating as an interval timer, as shown in figure 14.4. this function can be used to generate interrupt requests at regular intervals.
403 tcnt count h'00 time h'ff wt/ it = 0 tme = 1 wovi overflow overflow overflow overflow legend: wovi: interval timer interrupt re q uest g eneration wovi wovi wovi figure 14.4 operation in interval timer mode 14.3.3 timing of setting of overflow flag (ovf) the ovf flag is set to 1 if tcnt overflows during interval timer operation. at the same time, an interval timer interrupt (wovi) is requested. this timing is shown in figure 14.5. if nmi request generation is selected in watchdog timer mode, when tcnt overflows the ovf bit in tcsr is set to 1 and at the same time an nmi interrupt is requested. tcnt h'ff h'00 overflow signal (internal signal) ovf figure 14.5 timing of ovf setting
404 14.3.4 reso signal output timing when tcnt overflows in watchdog timer mode, the ovf bit is set to 1 in tcsr. if the rst/ nmi bit is 1 at this time, an internal reset signal is generated for the entire chip, and at the same time a low-level signal is output from the reso pin. the timing is shown in figure 14.6. tcnt h'ff h'00 132 states 518 states overflow signal (internal signal) ovf reso signal internal reset signal figure 14.6 reso signal output timing 14.4 interrupts during interval timer mode operation, an overflow generates an interval timer interrupt (wovi). the interval timer interrupt is requested whenever the ovf flag is set to 1 in tcsr. ovf must be cleared to 0 in the interrupt handling routine. when nmi interrupt request generation is selected in watchdog timer mode, an overflow generates an nmi interrupt request.
405 14.5 usage notes 14.5.1 contention between timer counter (tcnt) write and increment if a timer counter clock pulse is generated during the t 2 state of a tcnt write cycle, the write takes priority and the timer counter is not incremented. figure 14.7 shows this operation. address internal write signal tcnt input clock tcnt nm t 1 t 2 tcnt write cycle counter write data figure 14.7 contention between tcnt write and increment 14.5.2 changing value of cks2 to cks0 if bits cks2 to cks0 in tcsr are written to while the wdt is operating, errors could occur in the incrementation. software must stop the watchdog timer (by clearing the tme bit to 0) before changing the value of bits cks2 to cks0. 14.5.3 switching between watchdog timer mode and interval timer mode if the mode is switched from watchdog timer to interval timer, or vice versa, while the wdt is operating, errors could occur in the incrementation. software must stop the watchdog timer (by clearing the tme bit to 0) before switching the mode.
406 14.5.4 system reset by reso signal if the reso output signal is input to the chip? res pin, the chip will not be initialized correctly. ensure that the reso signal is not logically input to the chip? res pin. when resetting the entire system with the reso signal, use a circuit such as that shown in figure 14.8. reset input reset signal to entire system chip res reso figure 14.8 sample circuit for system reset by reso signal 14.5.5 counter value in transitions between high-speed mode, subactive mode, and watch mode if the mode is switched between high-speed mode and subactive mode or between high-speed mode and watch mode when wdt1 is used as a realtime clock counter, an error will occur in the counter value when the internal clock is switched. when the mode is switched from high-speed mode to subactive mode or watch mode, the increment timing is delayed by approximately 2 or 3 clock cycles when the wdt1 control clock is switched from the main clock to the subclock. also, since the main clock oscillator is halted during subclock operation, when the mode is switched from watch mode or subactive mode to high-speed mode, the clock is not supplied until internal oscillation stabilizes. as a result, after oscillation is started, counter incrementing is halted during the oscillation stabilization time set by bits sts2 to sts0 in sbycr, and there is a corresponding discrepancy in the counter value. caution is therefore required when using wdt1 as the realtime clock counter. no error occurs in the counter value while wdt1 is operating in the same mode.
407 14.5.6 ovf flag clear condition to clear ovf flag in wovi handling routine, read tcsr when ovf=1, then write with 0 to ovf, as stated above. when wovi is masked and ovf flag is poling, if contention between ovf flag set and tcsr read is occurred, ovf=1 is read but ovf can not be cleared by writing with 0 to ovf. in this case, reading tcsr when ovf=1 two times meet the requirements of ovf clear condition. please read tcsr when ovf=1 two times before writing with 0 to ovf. loop btst.b #7,@tcsr ; ovf flag read beq loop ; if ovf=1, exit from loop mov.b @tcsr,r0l ; ovf=1 read again mov.w #h'a521,r0 ; ovf flag clear mov.w r0,@tcsr ; :
408
409 section 15 serial communication interface (sci, irda) 15.1 overview the h8s/2169 or h8s/2149 is equipped with a 3-channel serial communication interface (sci). the sci can handle both asynchronous and clocked synchronous serial communication. a function is also provided for serial communication between processors (multiprocessor communication function). one of the three sci channels can transmit and receive irda communication waveforms based on irda specification version 1.0. 15.1.1 features sci features are listed below. ? choice of asynchronous or synchronous serial communication mode asynchronous mode ? serial data communication is executed using an asynchronous system in which synchronization is achieved character by character serial data communication can be carried out with standard asynchronous communication chips such as a universal asynchronous receiver/transmitter (uart) or asynchronous communication interface adapter (acia) ? a multiprocessor communication function is provided that enables serial data communication with a number of processors ? choice of 12 serial data transfer formats data length: 7 or 8 bits stop bit length: 1 or 2 bits parity: even, odd, or none multiprocessor bit: 1 or 0 ? receive error detection: parity, overrun, and framing errors ? break detection: break can be detected by reading the rxd pin level directly in case of a framing error synchronous mode ? serial data communication is synchronized with a clock serial data communication can be carried out with other chips that have a synchronous communication function ? one serial data transfer format data length: 8 bits ? receive error detection: overrun errors detected
410 full-duplex communication capability ? the transmitter and receiver are mutually independent, enabling transmission and reception to be executed simultaneously ? double-buffering is used in both the transmitter and the receiver, enabling continuous transmission and continuous reception of serial data ? lsb-first or msb-first transfer can be selected ? this selection can be made regardless of the communication mode (with the exception of 7- bit data transfer in asynchronous mode)* note: * lsb-first transfer is used in the examples in this section. ? built-in baud rate generator allows any bit rate to be selected ? choice of serial clock source: internal clock from baud rate generator or external clock from sck pin ? capability of transmit and receive clock output ? the p86/sck and p42/sck2 pins are cmos type outputs ? the p52/sck0 pin is an nmos push-pull type output (when using the p52/sck pin as an output, an external pull-up resistor must be connected in order to output high level) ? four interrupt sources ? four interrupt sources (transmit-data-empty, transmit-end, receive-data-full, and receive error) that can issue requests independently ? the transmit-data-empty interrupt and receive-data-full interrupt can activate the data transfer controller (dtc) to execute data transfer
411 15.1.2 block diagram figure 15.1 shows a block diagram of the sci. bus interface tdr rsr rdr module data bus tsr ssr scmr scr smr transmission/ reception control brr baud rate generator internal data bus rxd txd sck parity generation parity check clock external clock ?4 ?16 ?64 txi tei rxi eri legend: rsr: receive shift register rdr: receive data register tsr: transmit shift register tdr: transmit data register smr: serial mode register scr: serial control register ssr: serial status register scmr: serial interface mode register brr: bit rate register figure 15.1 block diagram of sci
412 15.1.3 pin configuration table 15.1 shows the serial pins used by the sci. table 15.1 sci pins channel pin name symbol * i/o function 0 serial clock pin 0 sck0 i/o sci0 clock input/output receive data pin 0 rxd0 input sci0 receive data input transmit data pin 0 txd0 output sci0 transmit data output 1 serial clock pin 1 sck1 i/o sci1 clock input/output receive data pin 1 rxd1 input sci1 receive data input transmit data pin 1 txd1 output sci1 transmit data output 2 serial clock pin 2 sck2 i/o sci2 clock input/output receive data pin 2 rxd2/irrxd input sci2 receive data input (normal/irda) transmit data pin 2 txd2/irtxd output sci2 transmit data output (normal/irda) note: * the abbreviations sck, rxd, and txd are used in the text, omitting the channel number. 15.1.4 register configuration the sci has the internal registers shown in table 15.2. these registers are used to specify asynchronous mode or synchronous mode, the data format, and the bit rate, and to control the transmitter/receiver.
413 table 15.2 sci registers channel name abbreviation r/w initial value address * 1 0 serial mode register 0 smr0 r/w h'00 h'ffd8 * 3 bit rate register 0 brr0 r/w h'ff h'ffd9 * 3 serial control register 0 scr0 r/w h'00 h'ffda transmit data register 0 tdr0 r/w h'ff h'ffdb serial status register 0 ssr0 r/(w) * 2 h'84 h'ffdc receive data register 0 rdr0 r h'00 h'ffdd serial interface mode register 0 scmr0 r/w h'f2 h'ffde * 3 1 serial mode register 1 smr1 r/w h'00 h'ff88 * 3 bit rate register 1 brr1 r/w h'ff h'ff89 * 3 serial control register 1 scr1 r/w h'00 h'ff8a transmit data register 1 tdr1 r/w h'ff h'ff8b serial status register 1 ssr1 r/(w) * 2 h'84 h'ff8c receive data register 1 rdr1 r h'00 h'ff8d serial interface mode register 1 scmr1 r/w h'f2 h'ff8e * 3 2 serial mode register 2 smr2 r/w h'00 h'ffa0 * 3 bit rate register 2 brr2 r/w h'ff h'ffa1 * 3 serial control register 2 scr2 r/w h'00 h'ffa2 transmit data register 2 tdr2 r/w h'ff h'ffa3 serial status register 2 ssr2 r/(w) * 2 h'84 h'ffa4 receive data register 2 rdr2 r h'00 h'ffa5 serial interface mode register 2 scmr2 r/w h'f2 h'ffa6 * 3 keyboard comparator control register kbcomp r/w h'00 h'fee4 common module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. only 0 can be written, to clear flags. 3. some serial communication interface registers are assigned to the same addresses as other registers. in this case, register selection is performed by the iice bit in the serial timer control register (stcr).
414 15.2 register descriptions 15.2.1 receive shift register (rsr) 7 6 5 4 3 0 2 1 bit read/write rsr is a register used to receive serial data. the sci sets serial data input from the rxd pin in rsr in the order received, starting with the lsb (bit 0), and converts it to parallel data. when one byte of data has been received, it is transferred to rdr automatically. rsr cannot be directly read or written to by the cpu. 15.2.2 receive data register (rdr) 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write rdr is a register that stores received serial data. when the sci has received one byte of serial data, it transfers the received serial data from rsr to rdr where it is stored, and completes the receive operation. after this, rsr is receive-enabled. since rsr and rdr function as a double buffer in this way, continuous receive operations can be performed. rdr is a read-only register, and cannot be written to by the cpu. rdr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode.
415 15.2.3 transmit shift register (tsr) 7 6 5 4 3 0 2 1 bit read/write tsr is a register used to transmit serial data. to perform serial data transmission, the sci first transfers transmit data from tdr to tsr, then sends the data to the txd pin starting with the lsb (bit 0). when transmission of one byte is completed, the next transmit data is transferred from tdr to tsr, and transmission started, automatically. however, data transfer from tdr to tsr is not performed if the tdre bit in ssr is set to 1. tsr cannot be directly read or written to by the cpu. 15.2.4 transmit data register (tdr) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write tdr is an 8-bit register that stores data for serial transmission. when the sci detects that tsr is empty, it transfers the transmit data written in tdr to tsr and starts serial transmission. continuous serial transmission can be carried out by writing the next transmit data to tdr during serial transmission of the data in tsr. tdr can be read or written to by the cpu at all times. tdr is initialized to h'ff by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode.
416 15.2.5 serial mode register (smr) 7 c/a 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 o/e 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w bit initial value read/write smr is an 8-bit register used to set the sci? serial transfer format and select the baud rate generator clock source. smr can be read or written to by the cpu at all times. smr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7?ommunication mode (c/ a ): selects asynchronous mode or synchronous mode as the sci operating mode. bit 7 c/ a description 0 asynchronous mode (initial value) 1 synchronous mode bit 6?character length (chr): selects 7 or 8 bits as the data length in asynchronous mode. in synchronous mode, a fixed data length of 8 bits is used regardless of the chr setting. bit 6 chr description 0 8-bit data (initial value) 1 7-bit data * note: * when 7-bit data is selected, the msb (bit 7) of tdr is not transmitted, and lsb-first/msb- first selection is not available. bit 5?arity enable (pe): in asynchronous mode, selects whether or not parity bit addition is performed in transmission, and parity bit checking in reception. in synchronous mode, or when a multiprocessor format is used, parity bit addition and checking is not performed, regardless of the pe bit setting.
417 bit 5 pe description 0 parity bit addition and checking disabled (initial value) 1 parity bit addition and checking enabled * note: * when the pe bit is set to 1, the parity (even or odd) specified by the o/ e bit is added to transmit data before transmission. in reception, the parity bit is checked for the parity (even or odd) specified by the o/ e bit. bit 4?parity mode (o/ e ): selects either even or odd parity for use in parity addition and checking. the o/ e bit setting is only valid when the pe bit is set to 1, enabling parity bit addition and checking, in asynchronous mode. the o/ e bit setting is invalid in synchronous mode, when parity bit addition and checking is disabled in asynchronous mode, and when a multiprocessor format is used. bit 4 o/ e description 0 even parity * 1 (initial value) 1 odd parity * 2 notes: 1. when even parity is set, parity bit addition is performed in transmission so that the total number of 1 bits in the transmit character plus the parity bit is even. in reception, a check is performed to see if the total number of 1 bits in the receive character plus the parity bit is even. 2. when odd parity is set, parity bit addition is performed in transmission so that the total number of 1 bits in the transmit character plus the parity bit is odd. in reception, a check is performed to see if the total number of 1 bits in the receive character plus the parity bit is odd. bit 3?top bit length (stop): selects 1 or 2 bits as the stop bit length in asynchronous mode. the stop bit setting is only valid in asynchronous mode. if synchronous mode is set the stop bit setting is invalid since stop bits are not added. bit 3 stop description 0 1 stop bit * 1 (initial value) 1 2 stop bits * 2 notes: 1. in transmission, a single 1 bit (stop bit) is added to the end of a transmit character before it is sent. 2. in transmission, two 1 bits (stop bits) are added to the end of a transmit character before it is sent.
418 in reception, only the first stop bit is checked, regardless of the stop bit setting. if the second stop bit is 1, it is treated as a stop bit; if it is 0, it is treated as the start bit of the next transmit character. bit 2?ultiprocessor mode (mp): selects multiprocessor format. when multiprocessor format is selected, the pe bit and o/ e bit parity settings are invalid. the mp bit setting is only valid in asynchronous mode; it is invalid in synchronous mode. for details of the multiprocessor communication function, see section 15.3.3, multiprocessor communication function. bit 2 mp description 0 multiprocessor function disabled (initial value) 1 multiprocessor format selected bits 1 and 0?lock select 1 and 0 (cks1, cks0): these bits select the clock source for the baud rate generator. the clock source can be selected from ? ?4, ?16, and ?64, according to the setting of bits cks1 and cks0. for the relation between the clock source, the bit rate register setting, and the baud rate, see section 15.2.8, bit rate register. bit 1 bit 0 cks1 cks0 description 0 0 clock (initial value) 1 ?4 clock 1 0 ?16 clock 1 ?64 clock 15.2.6 serial control register (scr) 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w bit initial value read/write scr is a register that performs enabling or disabling of sci transfer operations, serial clock output in asynchronous mode, and interrupt requests, and selection of the serial clock source.
419 scr can be read or written to by the cpu at all times. scr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7?ransmit interrupt enable (tie): enables or disables transmit-data-empty interrupt (txi) request generation when serial transmit data is transferred from tdr to tsr and the tdre flag in ssr is set to 1. bit 7 tie description 0 transmit-data-empty interrupt (txi) request disabled * (initial value) 1 transmit-data-empty interrupt (txi) request enabled note: * txi interrupt request cancellation can be performed by reading 1 from the tdre flag, then clearing it to 0, or clearing the tie bit to 0. bit 6?eceive interrupt enable (rie): enables or disables receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request generation when serial receive data is transferred from rsr to rdr and the rdrf flag in ssr is set to 1. bit 6 rie description 0 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request disabled * (initial value) 1 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request enabled note: * rxi and eri interrupt request cancellation can be performed by reading 1 from the rdrf, fer, per, or orer flag, then clearing the flag to 0, or clearing the rie bit to 0. bit 5?ransmit enable (te): enables or disables the start of serial transmission by the sci. bit 5 te description 0 transmission disabled * 1 (initial value) 1 transmission enabled * 2 notes: 1. the tdre flag in ssr is fixed at 1. 2. in this state, serial transmission is started when transmit data is written to tdr and the tdre flag in ssr is cleared to 0. smr setting must be performed to decide the transmission format before setting the te bit to 1.
420 bit 4?receive enable (re): enables or disables the start of serial reception by the sci. bit 4 re description 0 reception disabled * 1 (initial value) 1 reception enabled * 2 notes: 1. clearing the re bit to 0 does not affect the rdrf, fer, per, and orer flags, which retain their states. 2. serial reception is started in this state when a start bit is detected in asynchronous mode or serial clock input is detected in synchronous mode. smr setting must be performed to decide the reception format before setting the re bit to 1. bit 3?ultiprocessor interrupt enable (mpie): enables or disables multiprocessor interrupts. the mpie bit setting is only valid in asynchronous mode when receiving with the mp bit in smr set to 1. the mpie bit setting is invalid in synchronous mode or when the mp bit is cleared to 0. bit 3 mpie description 0 multiprocessor interrupts disabled (normal reception performed) (initial value) [clearing conditions] ? when the mpie bit is cleared to 0 ? when data with mpb = 1 is received 1 multiprocessor interrupts enabled * receive interrupt (rxi) requests, receive-error interrupt (eri) requests, and setting of the rdrf, fer, and orer flags in ssr are disabled until data with the multiprocessor bit set to 1 is received. note: * when receive data including mpb = 0 is received, receive data transfer from rsr to rdr, receive error detection, and setting of the rdrf, fer, and orer flags in ssr , is not performed. when receive data with mpb = 1 is received, the mpb bit in ssr is set to 1, the mpie bit is cleared to 0 automatically, and generation of rxi and eri interrupts (when the tie and rie bits in scr are set to 1) and fer and orer flag setting is enabled. bit 2?ransmit end interrupt enable (teie): enables or disables transmit-end interrupt (tei) request generation if there is no valid transmit data in tdr when the msb is transmitted.
421 bit 2 teie description 0 transmit-end interrupt (tei) request disabled * (initial value) 1 transmit-end interrupt (tei) request enabled * note: * tei cancellation can be performed by reading 1 from the tdre flag in ssr, then clearing it to 0 and clearing the tend flag to 0, or clearing the teie bit to 0. bits 1 and 0?lock enable 1 and 0 (cke1, cke0): these bits are used to select the sci clock source and enable or disable clock output from the sck pin. the combination of the cke1 and cke0 bits determines whether the sck pin functions as an i/o port, the serial clock output pin, or the serial clock input pin. the setting of the cke0 bit, however, is only valid for internal clock operation (cke1 = 0) in asynchronous mode. the cke0 bit setting is invalid in synchronous mode, and in the case of external clock operation (cke1 = 1). the setting of bits cke1 and cke0 must be carried out before the sci? operating mode is determined using smr. for details of clock source selection, see table 15.9 in section 15.3, operation. bit 1 bit 0 cke1 cke0 description 0 0 asynchronous mode internal clock/sck pin functions as i/o port * 1 synchronous mode internal clock/sck pin functions as serial clock output * 1 1 asynchronous mode internal clock/sck pin functions as clock output * 2 synchronous mode internal clock/sck pin functions as serial clock output 1 0 asynchronous mode external clock/sck pin functions as clock input * 3 synchronous mode external clock/sck pin functions as serial clock input 1 asynchronous mode external clock/sck pin functions as clock input * 3 synchronous mode external clock/sck pin functions as serial clock input notes: 1. initial value 2. outputs a clock of the same frequency as the bit rate. 3. inputs a clock with a frequency 16 times the bit rate.
422 15.2.7 serial status register (ssr) 7 tdre 1 r/(w) * 6 rdrf 0 r/(w) * 5 orer 0 r/(w) * 4 fer 0 r/(w) * 3 per 0 r/(w) * 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r bit initial value read/write note: * only 0 can be written, to clear the flag. ssr is an 8-bit register containing status flags that indicate the operating status of the sci, and multiprocessor bits. ssr can be read or written to by the cpu at all times. however, 1 cannot be written to flags tdre, rdrf, orer, per, and fer. also note that in order to clear these flags they must be read as 1 beforehand. the tend flag and mpb flag are read-only flags and cannot be modified. ssr is initialized to h'84 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7?ransmit data register empty (tdre): indicates that data has been transferred from tdr to tsr and the next serial data can be written to tdr. bit 7 tdre description 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] (initial value) ? when the te bit in scr is 0 ? when data is transferred from tdr to tsr and data can be written to tdr bit 6?eceive data register full (rdrf): indicates that the received data is stored in rdr.
423 bit 6 rdrf description 0 [clearing conditions] (initial value) when 0 is written in rdrf after reading rdrf = 1 when the dtc is activated by an rxi interrupt and reads data from rdr 1 [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr note: rdr and the rdrf flag are not affected and retain their previous values when an error is detected during reception or when the re bit in scr is cleared to 0. if reception of the next data is completed while the rdrf flag is still set to 1, an overrun error will occur and the receive data will be lost. bit 5?overrun error (orer): indicates that an overrun error occurred during reception, causing abnormal termination. bit 5 orer description 0 [clearing condition] (initial value) * 1 when 0 is written in orer after reading orer = 1 1 [setting condition] when the next serial reception is completed while rdrf = 1 * 2 notes: 1. the orer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. the receive data prior to the overrun error is retained in rdr, and the data received subsequently is lost. also, subsequent serial reception cannot be continued while the orer flag is set to 1. in synchronous mode, serial transmission cannot be continued, either. bit 4?raming error (fer): indicates that a framing error occurred during reception in asynchronous mode, causing abnormal termination.
424 bit 4 fer description 0 [clearing condition] (initial value) * 1 when 0 is written in fer after reading fer = 1 1 [setting condition] when the sci checks the stop bit at the end of the receive data when reception ends, and the stop bit is 0 * 2 notes: 1. the fer flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. in 2-stop-bit mode, only the first stop bit is checked for a value of 0; the second stop bit is not checked. if a framing error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the fer flag is set to 1. in synchronous mode, serial transmission cannot be continued, either. bit 3?arity error (per): indicates that a parity error occurred during reception using parity addition in asynchronous mode, causing abnormal termination. bit 3 per description 0 [clearing condition] (initial value) * 1 when 0 is written in per after reading per = 1 1 [setting condition] when, in reception, the number of 1 bits in the receive data plus the parity bit does not match the parity setting (even or odd) specified by the o/ e bit in smr * 2 notes: 1. the per flag is not affected and retains its previous state when the re bit in scr is cleared to 0. 2. if a parity error occurs, the receive data is transferred to rdr but the rdrf flag is not set. also, subsequent serial reception cannot be continued while the per flag is set to 1. in synchronous mode, serial transmission cannot be continued, either.
425 bit 2?transmit end (tend): indicates that there is no valid data in tdr when the last bit of the transmit character is sent, and transmission has been ended. the tend flag is read-only and cannot be modified. bit 2 tend description 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] (initial value) ? when the te bit in scr is 0 ? when tdre = 1 at transmission of the last bit of a 1-byte serial transmit character bit 1?ultiprocessor bit (mpb): when reception is performed using a multiprocessor format in asynchronous mode, mpb stores the multiprocessor bit in the receive data. mpb is a read-only bit, and cannot be modified. bit 1 mpb description 0 [clearing condition] (initial value) * when data with a 0 multiprocessor bit is received 1 [setting condition] when data with a 1 multiprocessor bit is received note: * retains its previous state when the re bit in scr is cleared to 0 with multiprocessor format. bit 0?ultiprocessor bit transfer (mpbt): when transmission is performed using a multiprocessor format in asynchronous mode, mpbt stores the multiprocessor bit to be added to the transmit data. the mpbt bit setting is invalid when a multiprocessor format is not used, when not transmitting, and in synchronous mode. bit 0 mpbt description 0 data with a 0 multiprocessor bit is transmitted (initial value) 1 data with a 1 multiprocessor bit is transmitted
426 15.2.8 bit rate register (brr) 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write brr is an 8-bit register that sets the serial transfer bit rate in accordance with the baud rate generator operating clock selected by bits cks1 and cks0 in smr. brr can be read or written to by the cpu at all times. brr is initialized to h'ff by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. as baud rate generator control is performed independently for each channel, different values can be set for each channel. table 15.3 shows sample brr settings in asynchronous mode, and table 15.4 shows sample brr settings in synchronous mode.
427 table 15.3 brr settings for various bit rates (asynchronous mode) operating frequency ? (mhz) ? = 2 mhz ? = 2.097152 mhz ? = 2.4576 mhz ? = 3 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 1 141 0.03 1 148 e0.04 1 174 e0.26 1 212 0.03 150 1 103 0.16 1 108 0.21 1 127 0.00 1 155 0.16 300 0 207 0.16 0 217 0.21 0 255 0.00 1 77 0.16 600 0 103 0.16 0 108 0.21 0 127 0.00 0 155 0.16 1200 0 51 0.16 0 54 e0.70 0 63 0.00 0 77 0.16 2400 0 25 0.16 0 26 1.14 0 31 0.00 0 38 0.16 4800 0 12 0.16 0 13 e2.48 0 15 0.00 0 19 e2.34 9600 ? ? ? 0 6 e2.48 0 7 0.00 0 9 e2.34 19200 ??????0 3 0.00 0 4 e2.34 31250 0 1 0.00 ??????0 2 0.00 38400 ??????0 1 0.00 ? ? ? operating frequency ? (mhz) ? = 3.6864 mhz ? = 4 mhz ? = 4.9152 mhz ? = 5 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 64 0.70 2 70 0.03 2 86 0.31 2 88 e0.25 150 1 191 0.00 1 207 0.16 1 255 0.00 2 64 0.16 300 1 95 0.00 1 103 0.16 1 127 0.00 1 129 0.16 600 0 191 0.00 0 207 0.16 0 255 0.00 1 64 0.16 1200 0 95 0.00 0 103 0.16 0 127 0.00 0 129 0.16 2400 0 47 0.00 0 51 0.16 0 63 0.00 0 64 0.16 4800 0 23 0.00 0 25 0.16 0 31 0.00 0 32 e1.36 9600 0 11 0.00 0 12 0.16 0 15 0.00 0 15 1.73 19200 0 5 0.00 ? ? ? 0 7 0.00 0 7 1.73 31250 ? ? ? 0 3 0.00 0 4 e1.70 0 4 0.00 38400 0 2 0.00 ? ? ? 0 3 0.00 0 3 1.73
428 operating frequency ? (mhz) ? = 6 mhz ? = 6.144 mhz ? = 7.3728 mhz ? = 8 mhz bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 106 e0.44 2 108 0.08 2 130 e0.07 2 141 0.03 150 2 77 0.16 2 79 0.00 2 95 0.00 2 103 0.16 300 1 155 0.16 1 159 0.00 1 191 0.00 1 207 0.16 600 1 77 0.16 1 79 0.00 1 95 0.00 1 103 0.16 1200 0 155 0.16 0 159 0.00 0 191 0.00 0 207 0.16 2400 0 77 0.16 0 79 0.00 0 95 0.00 0 103 0.16 4800 0 38 0.16 0 39 0.00 0 47 0.00 0 51 0.16 9600 0 19 e2.34 0 19 0.00 0 23 0.00 0 25 0.16 19200 0 9 e2.34 0 9 0.00 0 11 0.00 0 12 0.16 31250 0 5 0.00 0 5 2.40 ? ? ? 0 7 0.00 38400 0 4 e2.34 0 4 0.00 0 5 0.00 ? ? ? operating frequency ? (mhz) ? = 9.8304 mhz ? = 10 mhz bit rate (bits/s) n n error (%) n n error (%) 110 2 174 e0.26 2 177 e0.25 150 2 127 0.00 2 129 0.16 300 1 255 0.00 2 64 0.16 600 1 127 0.00 1 129 0.16 1200 0 255 0.00 1 64 0.16 2400 0 127 0.00 0 129 0.16 4800 0 63 0.00 0 64 0.16 9600 0 31 0.00 0 32 e1.36 19200 0 15 0.00 0 15 1.73 31250 0 9 e1.70 0 9 0.00 38400 0 7 0.00 0 7 1.73 note: as far as possible, the setting should be made so that the error is no more than 1% maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz. legend: ?: can be set, but there will be a degree of error.
429 table 15.4 brr settings for various bit rates (synchronous mode) operating frequency ? (mhz) bit rate ? = 2 mhz ? = 4 mhz ? = 8 mhz ? = 10 mhz (bits/s) n n n n n n n n 110 3 70 ? ? 250 2 124 2 249 3 124 ? ? 500 1 249 2 124 2 249 ? ? 1 k 1 124 1 249 2 124 ? ? 2.5 k 0 199 1 99 1 199 1 249 5 k 0 99 0 199 1 99 1 124 10 k 0 49 0 99 0 199 0 249 25 k 0 19 0 39 0 79 0 99 50 k 09019039049 100 k 0409019024 250 k 01030709 500 k 0 0 * 010304 1 m 0 0 * 01 2.5 m 00 * 5 m note: as far as possible, the setting should be made so that the error is no more than 1%. maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz. legend: blank: cannot be set. ? can be set, but there will be a degree of error. * : continuous transfer is not possible.
430 the brr setting is found from the following equations. asynchronous mode: n = 10 6 ?1 64 2 2n? b f synchronous mode: n = 10 6 ?1 8 2 2n? b f where b: bit rate (bits/s) n: brr setting for baud rate generator (0 n 255) ? operating frequency (mhz) n: baud rate generator input clock (n = 0 to 3) (see the table below for the relation between n and the clock.) smr setting n clock cks1 cks0 0 0 0 1 ?4 0 1 2 ?16 1 0 3 ?64 1 1 the bit rate error in asynchronous mode is found from the following equation: error (%) = ?1 100 (n + 1) b 64 2 2n? f 10 6 ? ?
431 table 15.5 shows the maximum bit rate for each frequency in asynchronous mode. tables 15.6 and 15.7 show the maximum bit rates with external clock input. table 15.5 maximum bit rate for each frequency (asynchronous mode) ?(mhz) maximum bit rate (bits/s) n n 2 62500 0 0 2.097152 65536 0 0 2.4576 76800 0 0 3 93750 0 0 3.6864 115200 0 0 4 125000 0 0 4.9152 153600 0 0 5 156250 0 0 6 187500 0 0 6.144 192000 0 0 7.3728 230400 0 0 8 250000 0 0 9.8304 307200 0 0 10 312500 0 0 note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz.
432 table 15.6 maximum bit rate with external clock input (asynchronous mode) ? (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.5000 31250 2.097152 0.5243 32768 2.4576 0.6144 38400 3 0.7500 46875 3.6864 0.9216 57600 4 1.0000 62500 4.9152 1.2288 76800 5 1.2500 78125 6 1.5000 93750 6.144 1.5360 96000 7.3728 1.8432 115200 8 2.0000 125000 9.8304 2.4576 153600 10 2.5000 156250 note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz. table 15.7 maximum bit rate with external clock input (synchronous mode) ? (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.3333 333333.3 4 0.6667 666666.7 6 1.0000 1000000.0 8 1.3333 1333333.3 10 1.6667 1666666.7 note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz.
433 15.2.9 serial interface mode register (scmr) 7 1 6 1 5 1 4 1 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 1 bit initial value read/write scmr is an 8-bit readable/writable register used to select sci functions. scmr is initialized to h'f2 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 to 4?eserved: these bits cannot be modified and are always read as 1. bit 3?ata transfer direction (sdir): selects the serial/parallel conversion format. bit 3 sdir description 0 tdr contents are transmitted lsb-first (initial value) receive data is stored in rdr lsb-first 1 tdr contents are transmitted msb-first receive data is stored in rdr msb-first bit 2?ata invert (sinv): specifies inversion of the data logic level. the sinv bit does not affect the logic level of the parity bit(s): parity bit inversion requires inversion of the o/ e bit in smr. bit 2 sinv description 0 tdr contents are transmitted without modification (initial value) receive data is stored in rdr without modification 1 tdr contents are inverted before being transmitted receive data is stored in rdr in inverted form bit 1?eserved: this bit cannot be modified and is always read as 1. bit 0?erial communication interface mode select (smif): reserved bit. 1 should not be written in this bit.
434 bit 0 smif description 0 normal sci mode (initial value) 1 reserved mode 15.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when bit mstp7, mstp6, or mstp5 is set to 1, sci0, sci1, or sci2 operation, respectively, stops at the end of the bus cycle and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?odule stop (mstp7): specifies the sci0 module stop mode. mstpcrl bit 7 mstp7 description 0 sci0 module stop mode is cleared 1 sci0 module stop mode is set (initial value) bit 6?odule stop (mstp6): specifies the sci1 module stop mode. mstpcrl bit 6 mstp6 description 0 sci1 module stop mode is cleared 1 sci1 module stop mode is set (initial value)
435 bit 5?module stop (mstp5): specifies the sci2 module stop mode. mstpcrl bit 5 mstp5 description 0 sci2 module stop mode is cleared 1 sci2 module stop mode is set (initial value) 15.2.11 keyboard comparator control register (kbcomp) 7 ire 0 r/w 6 ircks2 0 r/w 5 ircks1 0 r/w 4 ircks0 0 r/w 3 kbade 0 r/w 0 kbch0 0 r/w 2 kbch2 0 r/w 1 kbch1 0 r/w bit initial value read/write kbcomp is an 8-bit readable/writable register that selects the functions of sci2 and the a/d converter. kbcomp is initialized to h'00 by a reset and in hardware standby mode. bit 7?rda enable (ire): specifies normal sci operation or irda operation for sci2 input/output. bit 7 ire description 0 the txd2/irtxd and rxd2/irrxd pins function as txd2 and rxd2 (initial value) 1 the txd2/irtxd and rxd2/irrxd pins function as irtxd and irrxd bits 6 to 4?rda clock select 2 to 0 (ircks2 to ircks0): these bits specify the high pulse width in irtxd output pulse encoding when the irda function is enabled.
436 bit 6 bit 5 bit 4 ircks2 ircks1 ircks0 description 000b 3/16 (3/16 of the bit rate) (initial value) 1 ?/2 1 0 ?/4 1 ?/8 1 0 0 ?/16 1 ?/32 1 0 ?/64 1 ?/128 bits 3 to 0?keyboard comparator control: see the description in section 20, a/d converter.
437 15.3 operation 15.3.1 overview the sci can carry out serial communication in two modes: asynchronous mode in which synchronization is achieved character by character, and synchronous mode in which synchronization is achieved with clock pulses. selection of asynchronous or synchronous mode and the transmission format is made using smr as shown in table 15.8. the sci clock is determined by a combination of the c/ a bit in smr and the cke1 and cke0 bits in scr, as shown in table 15.9. asynchronous mode ? data length: choice of 7 or 8 bits ? choice of parity addition, multiprocessor bit addition, and addition of 1 or 2 stop bits (the combination of these parameters determines the transfer format and character length) ? detection of framing, parity, and overrun errors, and breaks, during reception ? choice of internal or external clock as sci clock source ? when internal clock is selected: the sci operates on the baud rate generator clock and a clock with the same frequency as the bit rate can be output ? when external clock is selected: a clock with a frequency of 16 times the bit rate must be input (the built-in baud rate generator is not used) synchronous mode ? transfer format: fixed 8-bit data ? detection of overrun errors during reception ? choice of internal or external clock as sci clock source ? when internal clock is selected: the sci operates on the baud rate generator clock and a serial clock is output off-chip ? when external clock is selected: the built-in baud rate generator is not used, and the sci operates on the input serial clock
438 table 15.8 smr settings and serial transfer format selection smr settings sci transfer format bit 7 bit 6 bit 2 bit 5 bit 3 data multi- processor parity stop bit c/ a chr mp pe stop mode length bit bit length 00000 asynchronous 8-bit data no no 1 bit 1 mode 2 bits 1 0 yes 1 bit 1 2 bits 1 0 0 7-bit data no 1 bit 1 2 bits 1 0 yes 1 bit 1 2 bits 0 1 ? 0 asynchronous 8-bit data yes no 1 bit ?1 mode (multi- 2 bits 1?0 processor 7-bit data 1 bit ?1 format) 2 bits 1 ???? synchronous mode 8-bit data no none table 15.9 smr and scr settings and sci clock source selection smr scr setting sci transfer clock bit 7 bit 1 bit 0 clock c/ a cke1 cke0 mode source sck pin function 0 0 0 asynchronous internal sci does not use sck pin 1 mode outputs clock with same frequency as bit rate 1 0 external inputs clock with frequency of 16 times 1 the bit rate 1 0 0 synchronous internal outputs serial clock 1 mode 1 0 external inputs serial clock 1
439 15.3.2 operation in asynchronous mode in asynchronous mode, characters are sent or received, each preceded by a start bit indicating the start of communication and followed by one or two stop bits indicating the end of communication. serial communication is thus carried out with synchronization established on a character-by- character basis. inside the sci, the transmitter and receiver are independent units, enabling full-duplex communication. both the transmitter and the receiver also have a double-buffered structure, so that data can be read or written during transmission or reception, enabling continuous data transfer. figure 15.2 shows the general format for asynchronous serial communication. in asynchronous serial communication, the transmission line is usually held in the mark state (high level). the sci monitors the transmission line, and when it goes to the space state (low level), recognizes a start bit and starts serial communication. one serial communication character consists of a start bit (low level), followed by data (in lsb- first order), a parity bit (high or low level), and finally one or two stop bits (high level). in asynchronous mode, the sci performs synchronization at the falling edge of the start bit in reception. the sci samples the data on the 8th pulse of a clock with a frequency of 16 times the length of one bit, so that the transfer data is latched at the center of each bit. lsb start bit msb idle state (mark state) stop bit(s) 0 transmit/receive data d0 d1 d2 d3 d4 d5 d6 d7 0/1 1 1 1 1 serial data parity bit 1 bit 1 or 2 bits 7 or 8 bits 1 bit, or none one unit of transfer data (character or frame) figure 15.2 data format in asynchronous communication (example with 8-bit data, parity, two stop bits)
440 data transfer format: table 15.10 shows the data transfer formats that can be used in asynchronous mode. any of 12 transfer formats can be selected by settings in smr. table 15.10 serial transfer formats (asynchronous mode) smr settings serial transfer format and frame length chr pe mp stop 123456789101112 0000 s 8-bit data stop 0001 s 8-bit data stop stop 0100 s 8-bit data p stop 0101 s 8-bit data p stop stop 1000 s 7-bit data stop 1001 s 7-bit data stop stop 1100 s 7-bit data p stop 1101 s 7-bit data p stop stop 0 1 0 s 8-bit data mpb stop 0 1 1 s 8-bit data mpb stop stop 1 1 0 s 7-bit data mpb stop 1 1 1 s 7-bit data mpb stop stop legend: s: start bit stop: stop bit p: parity bit mpb: multiprocessor bit
441 clock: either an internal clock generated by the built-in baud rate generator or an external clock input at the sck pin can be selected as the sci? serial clock, according to the setting of the c/ a bit in smr and the cke1 and cke0 bits in scr. for details of sci clock source selection, see table 15.9. when an external clock is input at the sck pin, the clock frequency should be 16 times the bit rate used. when the sci is operated on an internal clock, the clock can be output from the sck pin. the frequency of the clock output in this case is equal to the bit rate, and the phase is such that the rising edge of the clock is at the center of each transmit data bit, as shown in figure 15.3. 0 1 frame d0 d1 d2 d3 d4 d5 d6 d7 0/1 1 1 figure 15.3 relation between output clock and transfer data phase (asynchronous mode) data transfer operations sci initialization (asynchronous mode): before transmitting and receiving data, first clear the te and re bits in scr to 0, then initialize the sci as described below. when the operating mode, transfer format, etc., is changed, the te and re bits must be cleared to 0 before making the change using the following procedure. when the te bit is cleared to 0, the tdre flag is set to 1 and tsr is initialized. note that clearing the re bit to 0 does not change the contents of the rdrf, per, fer, and orer flags, or the contents of rdr. when an external clock is used the clock should not be stopped during operation, including initialization, since operation is uncertain.
442 figure 15.4 shows a sample sci initialization flowchart. wait start initialization set data transfer format in smr and scmr [1] set cke1 and cke0 bits in scr (te, re bits 0) no yes set value in brr clear te and re bits in scr to 0 [2] [3] set te and re bits in scr to 1, and set rie, tie, teie, and mpie bits [4] 1-bit interval elapsed? [1] set the clock selection in scr. be sure to clear bits rie, tie, teie, and mpie, and bits te and re, to 0. when the clock is selected in asynchronous mode, it is output immediately after scr settings are made. [2] set the data transfer format in smr and scmr. [3] write a value corresponding to the bit rate to brr. this is not necessary if an external clock is used. [4] wait at least one bit interval, then set the te bit or re bit in scr to 1. also set the rie, tie, teie, and mpie bits. setting the te and re bits enables the txd and rxd pins to be used. figure 15.4 sample sci initialization flowchart
443 serial data transmission (asynchronous mode): figure 15.5 shows a sample flowchart for serial transmission. the following procedure should be used for serial data transmission. no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and clear tdre flag in ssr to 0 no yes no yes read tend flag in ssr [3] no yes [4] clear dr to 0 and set ddr to 1 clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? break output? [1] sci initialization: the txd pin is automatically designated as the transmit data output pin. after the te bit is set to 1, one frame of 1s is output and transmission is enabled. [2] sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. [3] serial transmission continuation procedure: to continue serial transmission, read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request, and data is written to tdr. [4] break output at the end of serial transmission: to output a break in serial transmission, set ddr for the port corresponding to the txd pin to 1, clear dr to 0, then clear the te bit in scr to 0. figure 15.5 sample serial transmission flowchart
444 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit data empty interrupt (txi) is generated. the serial transmit data is sent from the txd pin in the following order. a. start bit: one 0-bit is output. b. transmit data: 8-bit or 7-bit data is output in lsb-first order. c. parity bit or multiprocessor bit: one parity bit (even or odd parity), or one multiprocessor bit is output. a format in which neither a parity bit nor a multiprocessor bit is output can also be selected. d. stop bit(s): one or two 1-bits (stop bits) are output. e. mark state: 1 is output continuously until the start bit that starts the next transmission is sent. 3. the sci checks the tdre flag at the timing for sending the stop bit. if the tdre flag is cleared to 0, the data is transferred from tdr to tsr, the stop bit is sent, and then serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the stop bit is sent, and then the mark state is entered in which 1 is output continuously. if the teie bit in scr is set to 1 at this time, a tei interrupt request is generated.
445 figure 15.6 shows an example of the operation for transmission in asynchronous mode. tdre tend 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit parity bit stop bit start bit data parity bit stop bit txi interrupt request generated data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated idle state (mark state) txi interrupt request generated figure 15.6 example of operation in transmission in asynchronous mode (example with 8-bit data, parity, one stop bit)
446 serial data reception (asynchronous mode): figure 15.7 shows a sample flowchart for serial reception. the following procedure should be used for serial data reception. yes [1] no initialization start reception [2] no yes read rdrf flag in ssr [4] [5] clear re bit in scr to 0 read orer, per, and fer flags in ssr error handling (continued on next page) [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes per fer orer= 1? rdrf= 1? all data received? sci initialization: the rxd pin is automatically designated as the receive data input pin. receive error handling and break detection: if a receive error occurs, read the orer, per, and fer flags in ssr to identify the error. after performing the appropriate error handling, ensure that the orer, per, and fer flags are all cleared to 0. reception cannot be resumed if any of these flags are set to 1. in the case of a framing error, a break can be detected by reading the value of the input port corresponding to the rxd pin. sci status check and receive data read : read ssr and check that rdrf = 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial reception continuation procedure: to continue serial reception, before the stop bit for the current frame is received, read the rdrf flag, read rdr, and clear the rdrf flag to 0. the rdrf flag is cleared automatically when the dtc is activated by an rxi interrupt and the rdr value is read. [1] [2] [3] [4] [5] figure 15.7 sample serial reception data flowchart
447 [3] error handling parity error handling no yes clear orer, per, and fer flags in ssr to 0 no yes no yes framing error handling no yes overrun error handling orer = 1? fer = 1? break? per = 1? clear re bit in scr to 0 figure 15.7 sample serial reception data flowchart (cont)
448 in serial reception, the sci operates as described below. 1. the sci monitors the transmission line, and if a 0 stop bit is detected, performs internal synchronization and starts reception. 2. the received data is stored in rsr in lsb-to-msb order. 3. the parity bit and stop bit are received. after receiving these bits, the sci carries out the following checks. a. parity check: the sci checks whether the number of 1 bits in the receive data agrees with the parity (even or odd) set in the o/ e bit in smr. b. stop bit check: the sci checks whether the stop bit is 1. if there are two stop bits, only the first is checked. c. status check: the sci checks whether the rdrf flag is 0, indicating that the receive data can be transferred from rsr to rdr. if all the above checks are passed, the rdrf flag is set to 1, and the receive data is stored in rdr. if a receive error* is detected in the error check, the operation is as shown in table 15.11. note: * subsequent receive operations cannot be performed when a receive error has occurred. also note that the rdrf flag is not set to 1 in reception, and so the error flags must be cleared to 0. 4. if the rie bit in scr is set to 1 when the rdrf flag changes to 1, a receive-data-full interrupt (rxi) request is generated. also, if the rie bit in scr is set to 1 when the orer, per, or fer flag changes to 1, a receive-error interrupt (eri) request is generated.
449 table 15.11 receive errors and conditions for occurrence receive error abbreviation occurrence condition data transfer overrun error orer when the next data reception is completed while the rdrf flag in ssr is set to 1 receive data is not transferred from rsr to rdr framing error fer when the stop bit is 0 receive data is transferred from rsr to rdr parity error per when the received data differs from the parity (even or odd) set in smr receive data is transferred from rsr to rdr figure 15.8 shows an example of the operation for reception in asynchronous mode. rdrf fer 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 0 1 1 data start bit parity bit stop bit start bit data parity bit stop bit rxi interrupt request generated eri interrupt request generated by framing error idle state (mark state) rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine figure 15.8 example of sci operation in reception (example with 8-bit data, parity, one stop bit)
450 15.3.3 multiprocessor communication function the multiprocessor communication function performs serial communication using a multiprocessor format, in which a multiprocessor bit is added to the transfer data, in asynchronous mode. use of this function enables data transfer to be performed among a number of processors sharing transmission lines. when multiprocessor communication is carried out, each receiving station is addressed by a unique id code. the serial communication cycle consists of two component cycles: an id transmission cycle which specifies the receiving station, and a data transmission cycle. the multiprocessor bit is used to differentiate between the id transmission cycle and the data transmission cycle. the transmitting station first sends the id of the receiving station with which it wants to perform serial communication as data with a 1 multiprocessor bit added. it then sends transmit data as data with a 0 multiprocessor bit added. the receiving station skips the data until data with a 1 multiprocessor bit is sent. when data with a 1 multiprocessor bit is received, the receiving station compares that data with its own id. the station whose id matches then receives the data sent next. stations whose id does not match continue to skip the data until data with a 1 multiprocessor bit is again received. in this way, data communication is carried out among a number of processors. figure 15.9 shows an example of inter-processor communication using a multiprocessor format. data transfer format: there are four data transfer formats. when a multiprocessor format is specified, the parity bit specification is invalid. for details, see table 15.10. clock: see the section on asynchronous mode.
451 transmitting station receiving station a (id = 01) receiving station b (id = 02) receiving station c (id = 03) receiving station d (id = 04) serial communication line serial data id transmission cycle: receiving station specification data transmission cycle: data transmission to receiving station specified by id (mpb = 1) (mpb = 0) h'01 h'aa legend: mpb: multiprocessor bit figure 15.9 example of inter-processor communication using multiprocessor format (transmission of data h'aa to receiving station a) data transfer operations multiprocessor serial data transmission: figure 15.10 shows a sample flowchart for multiprocessor serial data transmission. the following procedure should be used for multiprocessor serial data transmission.
452 no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and set mpbt bit in ssr no yes no yes read tend flag in ssr [3] no yes [4] clear dr to 0 and set ddr to 1 clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? break output? clear tdre flag to 0 sci initialization: the txd pin is automatically designated as the transmit data output pin. after the te bit is set to 1, one frame of 1s is output and transmission is enabled. sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr. set the mpbt bit in ssr to 0 or 1. finally, clear the tdre flag to 0. serial transmission continuation procedure: to continue serial transmission, be sure to read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit- data-empty interrupt (txi) request, and data is written to tdr. break output at the end of serial transmission: to output a break in serial transmission, set the port ddr to 1, clear dr to 0, then clear the te bit in scr to 0. [1] [2] [3] [4] figure 15.10 sample multiprocessor serial transmission flowchart
453 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit-data-empty interrupt (txi) is generated. the serial transmit data is sent from the txd pin in the following order. a. start bit: one 0-bit is output. b. transmit data: 8-bit or 7-bit data is output in lsb-first order. c. multiprocessor bit one multiprocessor bit (mpbt value) is output. d. stop bit(s): one or two 1-bits (stop bits) are output. e. mark state: 1 is output continuously until the start bit that starts the next transmission is sent. 3. the sci checks the tdre flag at the timing for sending the stop bit. if the tdre flag is cleared to 0, data is transferred from tdr to tsr, the stop bit is sent, and then serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the stop bit is sent, and then the mark state is entered in which 1 is output continuously. if the teie bit in scr is set to 1 at this time, a transmit-end interrupt (tei) request is generated.
454 figure 15.11 shows an example of sci operation for transmission using a multiprocessor format. tdre tend 0 1 frame d0 d1 d7 0/1 1 0 d0 d1 d7 0/1 1 1 1 data start bit multi- proce- ssor bit stop bit start bit data multi- proces- sor bit stop bit txi interrupt request generated data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated idle state (mark state) txi interrupt request generated figure 15.11 example of sci operation in transmission (example with 8-bit data, multiprocessor bit, one stop bit) multiprocessor serial data reception: figure 15.12 shows a sample flowchart for multiprocessor serial reception. the following procedure should be used for multiprocessor serial data reception.
455 yes [1] no initialization start reception no yes [4] clear re bit in scr to 0 error handling (continued on next page) [5] no yes fer orer = 1? rdrf = 1? all data received? read mpie bit in scr [2] read orer and fer flags in ssr read rdrf flag in ssr [3] read receive data in rdr no yes this station's id? read orer and fer flags in ssr yes no read rdrf flag in ssr no yes fer orer = 1? read receive data in rdr rdrf = 1? sci initialization: the rxd pin is automatically designated as the receive data input pin. id reception cycle: set the mpie bit in scr to 1. sci status check, id reception and comparison: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and compare it with this station? id. if the data is not this station? id, set the mpie bit to 1 again, and clear the rdrf flag to 0. if the data is this station? id, clear the rdrf flag to 0. sci status check and data reception: read ssr and check that the rdrf flag is set to 1, then read the data in rdr. receive error handling and break detection: if a receive error occurs, read the orer and fer flags in ssr to identify the error. after performing the appropriate error handling, ensure that the orer and fer flags are both cleared to 0. reception cannot be resumed if either of these flags is set to 1. in the case of a framing error, a break can be detected by reading the rxd pin value. [1] [2] [3] [4] [5] figure 15.12 sample multiprocessor serial reception flowchart
456 error handling yes no clear orer, per, and fer flags in ssr to 0 no yes no yes framing error handling overrun error handling orer = 1? fer = 1? break? clear re bit in scr to 0 [5] figure 15.12 sample multiprocessor serial reception flowchart (cont)
457 figure 15.13 shows an example of sci operation for multiprocessor format reception. mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 data (id1) start bit mpb stop bit start bit data (data1) mpb stop bit rxi interrupt request (multiprocessor interrupt) generated mpie = 0 idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine if not this station? id, mpie bit is set to 1 again rxi interrupt request is not generated, and rdr retains its state id1 (a) data does not match station? id mpie rdr value 0 d0 d1 d7 1 1 0 d0 d1 d7 0 1 1 1 data (id2) start bit mpb stop bit start bit data (data2) mpb stop bit rxi interrupt request (multiprocessor interrupt) generated mpie = 0 idle state (mark state) rdrf rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine matches this station? id, so reception continues, and data is received in rxi interrupt handling routine mpie bit set to 1 again id2 (b) data matches station? id data2 id1 figure 15.13 example of sci operation in reception (example with 8-bit data, multiprocessor bit, one stop bit)
458 15.3.4 operation in synchronous mode in synchronous mode, data is transmitted or received in synchronization with clock pulses, making it suitable for high-speed serial communication. inside the sci, the transmitter and receiver are independent units, enabling full-duplex communication by use of a common clock. both the transmitter and the receiver also have a double-buffered structure, so that data can be read or written during transmission or reception, enabling continuous data transfer. figure 15.14 shows the general format for synchronous serial communication. don? care don? care one unit of transfer data (character or frame) bit 0 serial data serial clock bit 1 bit 3 bit 4 bit 5 lsb msb bit 2 bit 6 bit 7 * note: * high except in continuous transfer * figure 15.14 data format in synchronous communication in synchronous serial communication, data on the transmission line is output from one falling edge of the serial clock to the next. data is guaranteed valid at the rising edge of the serial clock. in synchronous serial communication, one character consists of data output starting with the lsb and ending with the msb. after the msb is output, the transmission line holds the msb state. in synchronous mode, the sci receives data in synchronization with the rising edge of the serial clock.
459 data transfer format: a fixed 8-bit data format is used. no parity or multiprocessor bits are added. clock: either an internal clock generated by the built-in baud rate generator or an external serial clock input at the sck pin can be selected, according to the setting of the c/ a bit in smr and the cke1 and cke0 bits in scr. for details on sci clock source selection, see table 15.9. when the sci is operated on an internal clock, the serial clock is output from the sck pin. eight serial clock pulses are output in the transfer of one character, and when no transfer is performed the clock is fixed high. when only receive operations are performed, however, the serial clock is output until an overrun error occurs or the re bit is cleared to 0. to perform receive operations in units of one character, select an external clock as the clock source. data transfer operations sci initialization (synchronous mode): before transmitting and receiving data, first clear the te and re bits in scr to 0, then initialize the sci as described below. when the operating mode, transfer format, etc., is changed, the te and re bits must be cleared to 0 before making the change using the following procedure. when the te bit is cleared to 0, the tdre flag is set to 1 and tsr is initialized. note that clearing the re bit to 0 does not change the settings of the rdrf, per, fer, and orer flags, or the contents of rdr. figure 15.15 shows a sample sci initialization flowchart.
460 wait start initialization set data transfer format in smr and scmr no yes set value in brr note: in simultaneous transmit and receive operations, the te bit and re bit should both be cleared to 0 or set to 1 simultaneously. clear te and re bits in scr to 0 [2] [3] set te and re bits in scr to 1, and set rie, tie, teie, and mpie bits [4] 1-bit interval elapsed? set cke1 and cke0 bits in scr (te, re bits 0) [1] [1] set the clock selection in scr. be sure to clear bits rie, tie, teie, and mpie, te and re, to 0. [2] set the data transfer format in smr and scmr. [3] write a value corresponding to the bit rate to brr. this is not necessary if an external clock is used. [4] wait at least one bit interval, then set the te bit or re bit in scr to 1. also set the rie, tie, teie, and mpie bits. setting the te and re bits enables the txd and rxd pins to be used. figure 15.15 sample sci initialization flowchart
461 serial data transmission (synchronous mode): figure 15.16 shows a sample flowchart for serial transmission. the following procedure should be used for serial data transmission. no [1] yes initialization start transmission read tdre flag in ssr [2] write transmit data to tdr and clear tdre flag in ssr to 0 no yes no yes read tend flag in ssr [3] clear te bit in scr to 0 tdre = 1? all data transmitted? tend = 1? [1] sci initialization: the txd pin is automatically designated as the transmit data output pin. [2] sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. [3] serial transmission continuation procedure: to continue serial transmission, be sure to read 1 from the tdre flag to confirm that writing is possible, then write data to tdr, and then clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request and data is written to tdr. figure 15.16 sample serial transmission flowchart
462 in serial transmission, the sci operates as described below. 1. the sci monitors the tdre flag in ssr, and if it is 0, recognizes that data has been written to tdr, and transfers the data from tdr to tsr. 2. after transferring data from tdr to tsr, the sci sets the tdre flag to 1 and starts transmission. if the tie bit is set to 1 at this time, a transmit-data-empty interrupt (txi) is generated. when clock output mode has been set, the sci outputs 8 serial clock pulses. when use of an external clock has been specified, data is output synchronized with the input clock. the serial transmit data is sent from the txd pin starting with the lsb (bit 0) and ending with the msb (bit 7). 3. the sci checks the tdre flag at the timing for sending the msb (bit 7). if the tdre flag is cleared to 0, data is transferred from tdr to tsr, and serial transmission of the next frame is started. if the tdre flag is set to 1, the tend flag in ssr is set to 1, the msb (bit 7) is sent, and the txd pin maintains its state. if the teie bit in scr is set to 1 at this time, a transmit-end interrupt (tei) request is generated. 4. after completion of serial transmission, the sck pin is held in a constant state. figure 15.17 shows an example of sci operation in transmission. transfer direction bit 0 serial data serial clock 1 frame tdre tend bit 1 bit 7 bit 0 bit 1 bit 7 bit 6 data written to tdr and tdre flag cleared to 0 in txi interrupt handling routine tei interrupt request generated txi interrupt request generated txi interrupt request generated figure 15.17 example of sci operation in transmission
463 serial data reception (synchronous mode): figure 15.18 shows a sample flowchart for serial reception. the following procedure should be used for serial data reception. when changing the operating mode from asynchronous to synchronous, be sure to check that the orer, per, and fer flags are all cleared to 0. the rdrf flag will not be set if the fer or per flag is set to 1, and neither transmit nor receive operations will be possible.
464 yes [1] no initialization start reception [2] no yes read rdrf flag in ssr [4] [5] clear re bit in scr to 0 error handling (continued below) [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes orer= 1? rdrf= 1? all data received? read orer flag in ssr [1] [2] [3] [4] [5] sci initialization: the rxd pin is automatically designated as the receive data input pin. receive error handling: if a receive error occurs, read the orer flag in ssr , and after performing the appropriate error handling, clear the orer flag to 0. transfer cannot be resumed if the orer flag is set to 1. sci status check and receive data read: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial reception continuation procedure: to continue serial reception, before the msb (bit 7) of the current frame is received, finish reading the rdrf flag, reading rdr, and clearing the rdrf flag to 0. the rdrf flag is cleared automatically when the dtc is activated by a receive-data-full interrupt (rxi) request and the rdr value is read. error handling overrun error handling [3] clear orer flag in ssr to 0 figure 15.18 sample serial reception flowchart
465 in serial reception, the sci operates as described below. 1. the sci performs internal initialization in synchronization with serial clock input or output. 2. the received data is stored in rsr in lsb-to-msb order. after reception, the sci checks whether the rdrf flag is 0 and the receive data can be transferred from rsr to rdr. if this check is passed, the rdrf flag is set to 1, and the receive data is stored in rdr. if a receive error is detected in the error check, the operation is as shown in table 15.11. neither transmit nor receive operations can be performed subsequently when a receive error has been found in the error check. 3. if the rie bit in scr is set to 1 when the rdrf flag changes to 1, a receive-data-full interrupt (rxi) request is generated. also, if the rie bit in scr is set to 1 when the orer flag changes to 1, a receive-error interrupt (eri) request is generated. figure 15.19 shows an example of sci operation in reception. bit 7 serial data serial clock 1 frame rdrf orer bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 rxi interrupt request generated rdr data read and rdrf flag cleared to 0 in rxi interrupt handling routine rxi interrupt request generated eri interrupt request generated by overrun error figure 15.19 example of sci operation in reception simultaneous serial data transmission and reception (synchronous mode): figure 15.20 shows a sample flowchart for simultaneous serial transmit and receive operations. the following procedure should be used for simultaneous serial data transmit and receive operations.
466 yes [1] no initialization start transmission/reception [5] error handling [3] read receive data in rdr, and clear rdrf flag in ssr to 0 no yes orer = 1? all data received? [2] read tdre flag in ssr no yes tdre = 1? write transmit data to tdr and clear tdre flag in ssr to 0 no yes rdrf = 1? read orer flag in ssr [4] read rdrf flag in ssr clear te and re bits in scr to 0 note: when switching from transmit or receive operation to simultaneous transmit and receive operations, first clear the te bit and re bit to 0, then set both these bits to 1 simultaneously. [1] [2] [3] [4] [5] sci initialization: the txd pin is designated as the transmit data output pin, and the rxd pin is designated as the receive data input pin, enabling simultaneous transmit and receive operations. sci status check and transmit data write: read ssr and check that the tdre flag is set to 1, then write transmit data to tdr and clear the tdre flag to 0. transition of the tdre flag from 0 to 1 can also be identified by a txi interrupt. receive error handling: if a receive error occurs, read the orer flag in ssr , and after performing the appropriate error handling, clear the orer flag to 0. transmission/reception cannot be resumed if the orer flag is set to 1. sci status check and receive data read: read ssr and check that the rdrf flag is set to 1, then read the receive data in rdr and clear the rdrf flag to 0. transition of the rdrf flag from 0 to 1 can also be identified by an rxi interrupt. serial transmission/reception continuation procedure: to continue serial transmission/ reception, before the msb (bit 7) of the current frame is received, finish reading the rdrf flag, reading rdr, and clearing the rdrf flag to 0. also, before the msb (bit 7) of the current frame is transmitted, read 1 from the tdre flag to confirm that writing is possible, then write data to tdr and clear the tdre flag to 0. checking and clearing of the tdre flag is automatic when the dtc is activated by a transmit-data-empty interrupt (txi) request and data is written to tdr. also, the rdrf flag is cleared automatically when the dtc is activated by a receive-data- full interrupt (rxi) request and the rdr value is read. figure 15.20 sample flowchart of simultaneous serial transmit and receive operations
467 15.3.5 irda operation figure 15.21 shows a block diagram of the irda function. when the irda function is enabled with bit ire in kbcomp, the sci channel 2 txd2 and rxd2 signals are subjected to waveform encoding/decoding conforming to irda specification version 1.0 (irtxd and irrxd pins). by connecting these pins to an infrared transceiver/receiver, it is possible to implement infrared transmission/reception conforming to the irda specification version 1.0 system. in the irda specification version 1.0 system, communication is started at a transfer rate of 9600 bps, and subsequently the transfer rate can be varied as necessary. as the irda interface in the h8s/2169 or h8s/2149 does not include a function for varying the transfer rate automatically, the transfer rate setting must be changed by software. irda pulse encoder pulse decoder kbcomp txd2/irtxd rxd2/irrxd sci2 txd rxd figure 15.21 block diagram of irda function transmission: in transmission, the output signal (uart frame) from the sci is converted to an ir frame by the irda interface (see figure 15.22). when the serial data is 0, a high-level pulses of 3/16 the bit rate (interval equivalent to the width of one bit) is output (initial value). the high-level pulse can be varied according to the setting of bits ircks2 to ircks0 in kbcomp. the high-level pulse width is fixed at a minimum of 1.41 m s, and a maximum of (3/16 + 2.5%) bit rate or (3/16 bit rate) + 1.08 m s.
468 when the serial data is 1, no pulse is output. 0000 0 uart frame ir frame data data start bit stop bit start bit stop bit 11 111 0000 0 11 111 pulse width is 1.6 s to 3/16 bit interval transmission reception bit interval figure 15.22 irda transmit/receive operations reception: in reception, ir frame data is converted to a uart frame by the irda interface, and input to the sci. when a high-level pulse is detected, 0 data is output, and if there is no pulse during a one-bit interval, 1 data is output. note that a pulse shorter than the minimum pulse width of 1.41 m s will be identified as a 0 signal. high-level pulse width selection: table 15.12 shows possible settings for bits ircks2 to ircks0 (minimum pulse width), and h8s/2169 or h8s/2149 operating frequencies and bit rates, for making the pulse width shorter than 3/16 times the bit rate in transmission.
469 table 15.12 bit ircks2 to ircks0 settings operating bit rate (bps) (upper row) / bit interval 3/16 ( m s) (lower row) frequency 2400 9600 19200 38400 57600 115200 ? (mhz) 78.13 19.53 9.77 4.88 3.26 1.63 2 010 010 010 010 010 ? 2.097152 010 010 010 010 010 ? 2.4576 010 010 010 010 010 ? 3 011 011 011 011 011 ? 3.6864 011 011 011 011 011 011 4.9152 011 011 011 011 011 011 5 011 011 011 011 011 011 6 100 100 100 100 100 100 6.144 100 100 100 100 100 100 7.3728 100 100 100 100 100 100 8 100 100 100 100 100 100 9.8304 100 100 100 100 100 100 10 100 100 100 100 100 100 note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz. legend: ?: an sci bit rate setting cannot be mode.
470 15.4 sci interrupts the sci has four interrupt sources: the transmit-end interrupt (tei) request, receive-error interrupt (eri) request, receive-data-full interrupt (rxi) request, and transmit-data-empty interrupt (txi) request. table 15.13 shows the interrupt sources and their relative priorities. individual interrupt sources can be enabled or disabled with the tie, rie, and teie bits in scr. each kind of interrupt request is sent to the interrupt controller independently. when the tdre flag in ssr is set to 1, a txi interrupt request is generated. when the tend flag in ssr is set to 1, a tei interrupt request is generated. a txi interrupt can activate the dtc to perform data transfer. the tdre flag is cleared to 0 automatically when data transfer is performed by the dtc. the dtc cannot be activated by a tei interrupt request. when the rdrf flag in ssr is set to 1, an rxi interrupt request is generated. when the orer, per, or fer flag in ssr is set to 1, an eri interrupt request is generated. an rxi interrupt can activate the dtc to perform data transfer. the rdrf flag is cleared to 0 automatically when data transfer is performed by the dtc. the dtc cannot be activated by an eri interrupt request. table 15.13 sci interrupt sources channel interrupt source description dtc activation priority * 0 eri receive error (orer, fer, or per) not possible high rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible 1 eri receive error (orer, per, or per) not possible rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible 2 eri receive error (orer, per, or per) not possible rxi receive data register full (rdrf) possible txi transmit data register empty (tdre) possible tei transmit end (tend) not possible low note: * the table shows the initial state immediately after a reset. relative channel priorities can be changed by the interrupt controller. the tei interrupt is requested when the tend flag is set to 1 while the teie bit is set to 1. the tend flag is cleared at the same time as the tdre flag. consequently, if a tei interrupt and a txi interrupt are requested simultaneously, the txi interrupt will have priority for acceptance,
471 and the tdre flag and tend flag may be cleared. note that the tei interrupt will not be accepted in this case. 15.5 usage notes the following points should be noted when using the sci. relation between writes to tdr and the tdre flag the tdre flag in ssr is a status flag that indicates that transmit data has been transferred from tdr to tsr. when the sci transfers data from tdr to tsr, the tdre flag is set to 1. data can be written to tdr regardless of the state of the tdre flag. however, if new data is written to tdr when the tdre flag is cleared to 0, the data stored in tdr will be lost since it has not yet been transferred to tsr. it is therefore essential to check that the tdre flag is set to 1 before writing transmit data to tdr. operation when multiple receive errors occur simultaneously if a number of receive errors occur at the same time, the state of the status flags in ssr is as shown in table 15.14. if there is an overrun error, data is not transferred from rsr to rdr, and the receive data is lost. table 15.14 state of ssr status flags and transfer of receive data ssr status flags receive data transfer rdrf orer fer per rsr to rdr receive errors 1100x overrun error 0010o framing error 0001o parity error 1110x overrun error + framing error 1101x overrun error + parity error 0011o framing error + parity error 1111x overrun error + framing error + parity error notes: o: receive data is transferred from rsr to rdr. x: receive data is not transferred from rsr to rdr.
472 break detection and processing: when a framing error (fer) is detected, a break can be detected by reading the rxd pin value directly. in a break, the input from the rxd pin becomes all 0s, and so the fer flag is set, and the parity error flag (per) may also be set. note that, since the sci continues the receive operation after receiving a break, even if the fer flag is cleared to 0, it will be set to 1 again. sending a break: the txd pin has a dual function as an i/o port whose direction (input or output) is determined by dr and ddr. this feature can be used to send a break. between serial transmission initialization and setting of the te bit to 1, the mark state is replaced by the value of dr (the pin does not function as the txd pin until the te bit is set to 1). consequently, ddr and dr for the port corresponding to the txd pin should first be set to 1. to send a break during serial transmission, first clear dr to 0, then clear the te bit to 0. when the te bit is cleared to 0, the transmitter is initialized regardless of the current transmission state, the txd pin becomes an i/o port, and 0 is output from the txd pin. receive error flags and transmit operations (synchronous mode only): transmission cannot be started when a receive error flag (orer, per, or fer) is set to 1, even if the tdre flag is cleared to 0. be sure to clear the receive error flags to 0 before starting transmission. note also that receive error flags cannot be cleared to 0 even if the re bit is cleared to 0. receive data sampling timing and reception margin in asynchronous mode: in asynchronous mode, the sci operates on a base clock with a frequency of 16 times the transfer rate. in reception, the sci samples the falling edge of the start bit using the base clock, and performs internal synchronization. receive data is latched internally at the rising edge of the 8th pulse of the base clock. this is illustrated in figure 15.23.
473 internal base clock 16 clocks 8 clocks receive data (rxd) synchronization sampling timing start bit d0 d1 data sampling timing 15 0 7 15 0 07 figure 15.23 receive data sampling timing in asynchronous mode thus the receive margin in asynchronous mode is given by equation (1) below. m = 0.5 ? 1 2n d ?0.5 n ?(l ?0.5)f ? (1 + f) 100% .......... (1) where m: receive margin (%) n: ratio of bit rate to clock (n = 16) d: clock duty (d = 0 to 1.0) l: frame length (l = 9 to 12) f: absolute value of clock rate deviation assuming values of f = 0 and d = 0.5 in equation (1), a receive margin of 46.875% is given by equation (2) below. when d = 0.5 and f = 0, m = 1 2 16 100% = 46.875% 0.5 .......... (2) however, this is only a theoretical value, and a margin of 20% to 30% should be allowed in system design.
474 restrictions on use of dtc when an external clock source is used as the serial clock, the transmit clock should not be input until at least 5 ?clock cycles after tdr is updated by the dtc. misoperation may occur if the transmit clock is input within 4 clock cycles after tdr is updated. (figure 15.24) ? when rdr is read by the dtc, be sure to set the activation source to the relevant sci receive- data-full interrupt (rxi). t d0 lsb serial data sck d1 d3 d4 d5 d2 d6 d7 note: when operating on an external clock, set t > 4 states. tdre figure 15.24 example of synchronous transmission by dtc
475 section 16 i 2 c bus interface 16.1 overview a two-channel i 2 c bus interface is available for the h8s/2169 or h8s/2149. the i 2 c bus interface conforms to and provides a subset of the philips i 2 c bus (inter-ic bus) interface functions. the register configuration that controls the i 2 c bus differs partly from the philips configuration, however. each i 2 c bus interface channel uses only one data line (sda) and one clock line (scl) to transfer data, saving board and connector space. 16.1.1 features ? selection of addressing format or non-addressing format ? i 2 c bus format: addressing format with acknowledge bit, for master/slave operation ? serial format: non-addressing format without acknowledge bit, for master operation only ? conforms to philips i 2 c bus interface (i 2 c bus format) ? two ways of setting slave address (i 2 c bus format) ? start and stop conditions generated automatically in master mode (i 2 c bus format) ? selection of acknowledge output levels when receiving (i 2 c bus format) ? automatic loading of acknowledge bit when transmitting (i 2 c bus format) ? wait function in master mode (i 2 c bus format) a wait can be inserted by driving the scl pin low after data transfer, excluding acknowledgement. the wait can be cleared by clearing the interrupt flag. ? wait function in slave mode (i 2 c bus format) a wait request can be generated by driving the scl pin low after data transfer, excluding acknowledgement. the wait request is cleared when the next transfer becomes possible. ? three interrupt sources ? data transfer end (including transmission mode transition with i 2 c bus format and address reception after loss of master arbitration) ? address match: when any slave address matches or the general call address is received in slave receive mode (i 2 c bus format) ? stop condition detection
476 ? selection of 16 internal clocks (in master mode) ? direct bus drive (with scl and sda pins) ? two pins?52/scl0 and p97/sda0?normally nmos push-pull outputs) function as nmos open-drain outputs when the bus drive function is selected. ? two pins?86/scl1 and p42/sda1?normally cmos pins) function as nmos-only outputs when the bus drive function is selected. ? automatic switching from formatless mode to i 2 c bus format (channel 0 only) ? formatless operation (no start/stop conditions, non-addressing mode) in slave mode ? operation using a common data pin (sda) and independent clock pins (vsynci, scl) ? automatic switching from formatless mode to i 2 c bus format on the fall of the scl pin 16.1.2 block diagram figure 16.1 shows a block diagram of the i 2 c bus interface. figure 16.2 shows an example of i/o pin connections to external circuits. channel 0 i/o pins and channel 1 i/o pins differ in structure, and have different specifications for permissible applied voltages. for details, see section 25, electrical characteristics.
477 ps noise canceler noise canceler clock control formatless dedicated clock (channel 0 only) bus state decision circuit arbitration decision circuit output data control circuit address comparator sar, sarx interrupt generator icdrs icdrr icdrt icsr icmr iccr internal data bus interrupt request scl sda legend: iccr: icmr: icsr: icdr: sar: sarx: ps: i 2 c bus control register i 2 c bus mode register i 2 c bus status register i 2 c bus data register slave address register slave address register x prescaler figure 16.1 block diagram of i 2 c bus interface
478 scl in scl out sda in sda out (slave 1) scl sda scl in scl out sda in sda out (slave 2) scl sda scl in scl out sda in sda out (master) h8s/2149 chip scl sda vcc vcc scl sda figure 16.2 i 2 c bus interface connections (example: h8s/2169 or h8s/2149 chip as master) 16.1.3 input/output pins table 16.1 summarizes the input/output pins used by the i 2 c bus interface. table 16.1 i 2 c bus interface pins channel name abbreviation * i/o function 0 serial clock scl0 i/o iic0 serial clock input/output serial data sda0 i/o iic0 serial data input/output formatless serial clock vsynci input iic0 formatless serial clock input 1 serial clock scl1 i/o iic1 serial clock input/output serial data sda1 i/o iic1 serial data input/output note: * in the text, the channel subscript is omitted, and only scl and sda are used.
479 16.1.4 register configuration table 16.2 summarizes the registers of the i 2 c bus interface. table 16.2 register configuration channel name abbreviation r/w initial value address * 1 0i 2 c bus control register iccr0 r/w h'01 h'ffd8 i 2 c bus status register icsr0 r/w h'00 h'ffd9 i 2 c bus data register icdr0 r/w h'ffde * 2 i 2 c bus mode register icmr0 r/w h'00 h'ffdf * 2 slave address register sar0 r/w h'00 h'ffdf * 2 second slave address register sarx0 r/w h'01 h'ffde * 2 1i 2 c bus control register iccr1 r/w h'01 h'ff88 i 2 c bus status register icsr1 r/w h'00 h'ff89 i 2 c bus data register icdr1 r/w h'ff8e * 2 i 2 c bus mode register icmr1 r/w h'00 h'ff8f * 2 slave address register sar1 r/w h'00 h'ff8f * 2 second slave address register sarx1 r/w h'01 h'ff8e * 2 common serial/timer control register stcr r/w h'00 h'ffc3 ddc switch register ddcswr r/w h'0f h'fee6 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. the register that can be written or read depends on the ice bit in the i 2 c bus control register. the slave address register can be accessed when ice = 0, and the i 2 c bus mode register can be accessed when ice = 1. the i 2 c bus interface registers are assigned to the same addresses as other registers. register selection is performed by means of the iice bit in the serial/timer control register (stcr).
480 16.2 register descriptions 16.2.1 i 2 c bus data register (icdr) bit initial value read/write 7 icdr7 r/w 6 icdr6 r/w 5 icdr5 r/w 4 icdr4 r/w 3 icdr3 r/w 0 icdr0 r/w 2 icdr2 r/w 1 icdr1 r/w ? icdrr bit initial value read/write 7 icdrr7 r 6 icdrr6 r 5 icdrr5 r 4 icdrr4 r 3 icdrr3 r 0 icdrr0 r 2 icdrr2 r 1 icdrr1 r ? icdrs bit initial value read/write 7 icdrs7 6 icdrs6 5 icdrr5 4 icdrs4 3 icdrs3 0 icdrs0 2 icdrs2 1 icdrs1 ? icdrt bit initial value read/write 7 icdrt7 w 6 icdrt6 w 5 icdrt5 w 4 icdrt4 w 3 icdrt3 w 0 icdrt0 w 2 icdrt2 w 1 icdrt1 w ? tdre, rdrf (internal flags) bit initial value read/write rdrf 0 tdre 0
481 icdr is an 8-bit readable/writable register that is used as a transmit data register when transmitting and a receive data register when receiving. icdr is divided internally into a shift register (icdrs), receive buffer (icdrr), and transmit buffer (icdrt). icdrs cannot be read or written by the cpu, icdrr is read-only, and icdrt is write-only. data transfers among the three registers are performed automatically in coordination with changes in the bus state, and affect the status of internal flags such as tdre and rdrf. if iic is in transmit mode and the next data is in icdrt (the tdre flag is 0) following transmission/reception of one frame of data using icdrs, data is transferred automatically from icdrt to icdrs. if iic is in receive mode and no previous data remains in icdrr (the rdrf flag is 0) following transmission/reception of one frame of data using icdrs, data is transferred automatically from icdrs to icdrr. if the number of bits in a frame, excluding the acknowledge bit, is less than 8, transmit data and receive data are stored differently. transmit data should be written justified toward the msb side when mls = 0, and toward the lsb side when mls = 1. receive data bits read from the lsb side should be treated as valid when mls = 0, and bits read from the msb side when mls = 1. icdr is assigned to the same address as sarx, and can be written and read only when the ice bit is set to 1 in iccr. the value of icdr is undefined after a reset. the tdre and rdrf flags are set and cleared under the conditions shown below. setting the tdre and rdrf flags affects the status of the interrupt flags.
482 tdre description 0 the next transmit data is in icdr (icdrt), or transmission cannot (initial value) be started [clearing conditions] ? when transmit data is written in icdr (icdrt) in transmit mode (trs = 1) ? when a stop condition is detected in the bus line state after a stop condition is issued with the i 2 c bus format or serial format selected ? when a stop condition is detected with the i 2 c bus format selected ? in receive mode (trs = 0) (a 0 write to trs during transfer is valid after reception of a frame containing an acknowledge bit) 1 the next transmit data can be written in icdr (icdrt) [setting conditions] ? in transmit mode (trs = 1), when a start condition is detected in the bus line state after a start condition is issued in master mode with the i 2 c bus format or serial format selected ? at the first transmit mode setting (trs = 1) (first transmit mode setting only) after i 2 c bus mode is switched to formatless mode ? when data is transferred from icdrt to icdrs (data transfer from icdrt to icdrs when trs = 1 and tdre = 0, and icdrs is empty) ? when receive mode (trs = 0) is switched to transmit mode (trs = 1 ) after detection of a start condition (first transmit mode setting only) rdrf description 0 the data in icdr (icdrr) is invalid (initial value) [clearing condition] when icdr (icdrr) receive data is read in receive mode 1 the icdr (icdrr) receive data can be read [setting condition] when data is transferred from icdrs to icdrr (data transfer from icdrs to icdrr in case of normal termination with trs = 0 and rdrf = 0)
483 16.2.2 slave address register (sar) bit initial value read/write 7 sva6 0 r/w 6 sva5 0 r/w 5 sva4 0 r/w 4 sva3 0 r/w 3 sva2 0 r/w 0 fs 0 r/w 2 sva1 0 r/w 1 sva0 0 r/w sar is an 8-bit readable/writable register that stores the slave address and selects the communication format. when the chip is in slave mode (and the addressing format is selected), if the upper 7 bits of sar match the upper 7 bits of the first frame received after a start condition, the chip operates as the slave device specified by the master device. sar is assigned to the same address as icmr, and can be written and read only when the ice bit is cleared to 0 in iccr. sar is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 1?lave address (sva6 to sva0): set a unique address in bits sva6 to sva0, differing from the addresses of other slave devices connected to the i 2 c bus. bit 0?ormat select (fs): used together with the fsx bit in sarx and the sw bit in ddcswr to select the communication format. ? i 2 c bus format: addressing format with acknowledge bit ? synchronous serial format: non-addressing format without acknowledge bit, for master mode only ? formatless mode (channel 0 only): non-addressing format with or without acknowledge bit, slave mode only, start/stop conditions not detected the fs bit also specifies whether or not sar slave address recognition is performed in slave mode.
484 ddcswr bit 6 sar bit 0 sarx bit 0 sw fs fsx operating mode 000 i 2 c bus format ? sar and sarx slave addresses recognized 1i 2 c bus format ? sar slave address recognized ? sarx slave address ignored (initial value) 10 i 2 c bus format ? sar slave address ignored ? sarx slave address recognized 1 synchronous serial format ? sar and sarx slave addresses ignored 10 0 1 0 1 0 formatless mode (start/stop conditions not detected) ? acknowledge bit used 1 1 formatless mode * (start/stop conditions not detected) ? no acknowledge bit note: * do not set this mode when automatic switching to the i 2 c bus format is performed by means of the ddcswr setting. 16.2.3 second slave address register (sarx) bit initial value read/write 7 svax6 0 r/w 6 svax5 0 r/w 5 svax4 0 r/w 4 svax3 0 r/w 3 svax2 0 r/w 0 fsx 1 r/w 2 svax1 0 r/w 1 svax0 0 r/w sarx is an 8-bit readable/writable register that stores the second slave address and selects the communication format. when the chip is in slave mode (and the addressing format is selected), if the upper 7 bits of sarx match the upper 7 bits of the first frame received after a start condition, the chip operates as the slave device specified by the master device. sarx is assigned to the same address as icdr, and can be written and read only when the ice bit is cleared to 0 in iccr. sarx is initialized to h'01 by a reset and in hardware standby mode. bits 7 to 1?econd slave address (svax6 to svax0): set a unique address in bits svax6 to svax0, differing from the addresses of other slave devices connected to the i 2 c bus.
485 bit 0?ormat select x (fsx): used together with the fs bit in sar and the sw bit in ddcswr to select the communication format. ? i 2 c bus format: addressing format with acknowledge bit ? synchronous serial format: non-addressing format without acknowledge bit, for master mode only ? formatless mode: non-addressing format with or without acknowledge bit, slave mode only, start/stop conditions not detected the fsx bit also specifies whether or not sarx slave address recognition is performed in slave mode. for details, see the description of the fs bit in sar. 16.2.4 i 2 c bus mode register (icmr) bit initial value read/write 7 mls 0 r/w 6 wait 0 r/w 5 cks2 0 r/w 4 cks1 0 r/w 3 cks0 0 r/w 0 bc0 0 r/w 2 bc2 0 r/w 1 bc1 0 r/w icmr is an 8-bit readable/writable register that selects whether the msb or lsb is transferred first, performs master mode wait control, and selects the master mode transfer clock frequency and the transfer bit count. icmr is assigned to the same address as sar. icmr can be written and read only when the ice bit is set to 1 in iccr. icmr is initialized to h'00 by a reset and in hardware standby mode. bit 7?sb-first/lsb-first select (mls): selects whether data is transferred msb-first or lsb-first. if the number of bits in a frame, excluding the acknowledge bit, is less than 8, transmit data and receive data are stored differently. transmit data should be written justified toward the msb side when mls = 0, and toward the lsb side when mls = 1. receive data bits read from the lsb side should be treated as valid when mls = 0, and bits read from the msb side when mls = 1. do not set this bit to 1 when the i 2 c bus format is used. bit 7 mls description 0 msb-first (initial value) 1 lsb-first
486 bit 6?ait insertion bit (wait): selects whether to insert a wait between the transfer of data and the acknowledge bit, in master mode with the i 2 c bus format. when wait is set to 1, after the fall of the clock for the final data bit, the iric flag is set to 1 in iccr, and a wait state begins (with scl at the low level). when the iric flag is cleared to 0 in iccr, the wait ends and the acknowledge bit is transferred. if wait is cleared to 0, data and acknowledge bits are transferred consecutively with no wait inserted. the iric flag in iccr is set to 1 on completion of the acknowledge bit transfer, regardless of the wait setting. the setting of this bit is invalid in slave mode. bit 6 wait description 0 data and acknowledge bits transferred consecutively (initial value) 1 wait inserted between data and acknowledge bits
487 bits 5 to 3?erial clock select (cks2 to cks0): these bits, together with the iicx1 (channel 1) or iicx0 (channel 0) bit in the stcr register, select the serial clock frequency in master mode. they should be set according to the required transfer rate. stcr bit 5 or 6 bit 5 bit 4 bit 3 transfer rate iicx cks2 cks1 cks0 clock ?= 5 mhz ?= 8 mhz ?= 10 mhz 0 0 0 0 ?28 179 khz 286 khz 357 khz 1 ?40 125 khz 200 khz 250 khz 1 0 ?48 104 khz 167 khz 208 khz 1 ?64 78.1 khz 125 khz 156 khz 1 0 0 ?80 62.5 khz 100 khz 125 khz 1 ?100 50.0 khz 80.0 khz 100 khz 1 0 ?112 44.6 khz 71.4 khz 89.3 khz 1 ?128 39.1 khz 62.5 khz 78.1 khz 1 0 0 0 ?56 89.3 khz 143 khz 179 khz 1 ?80 62.5 khz 100 khz 125 khz 1 0 ?96 52.1 khz 83.3 khz 104 khz 1 ?128 39.1 khz 62.5 khz 78.1 khz 1 0 0 ?160 31.3 khz 50.0 khz 62.5 khz 1 ?200 25.0 khz 40.0 khz 50.0 khz 1 0 ?224 22.3 khz 35.7 khz 44.6 khz 1 ?256 19.5 khz 31.3 khz 39.1 khz note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz.
488 bits 2 to 0?it counter (bc2 to bc0): bits bc2 to bc0 specify the number of bits to be transferred next. with the i 2 c bus format (when the fs bit in sar or the fsx bit in sarx is 0), the data is transferred with one addition acknowledge bit. bit bc2 to bc0 settings should be made during an interval between transfer frames. if bits bc2 to bc0 are set to a value other than 000, the setting should be made while the scl line is low. the bit counter is initialized to 000 by a reset and when a start condition is detected. the value returns to 000 at the end of a data transfer, including the acknowledge bit. bit 2 bit 1 bit 0 bits/frame bc2 bc1 bc0 synchronous serial format i 2 c bus format 0 0 0 8 9 (initial value) 11 2 10 2 3 13 4 100 4 5 15 6 10 6 7 17 8 16.2.5 i 2 c bus control register (iccr) bit initial value read/write note: * only 0 can be written, to clear the flag. 7 ice 0 r/w 6 ieic 0 r/w 5 mst 0 r/w 4 trs 0 r/w 3 acke 0 r/w 0 scp 1 w 2 bbsy 0 r/w 1 iric 0 r/(w) * iccr is an 8-bit readable/writable register that enables or disables the i 2 c bus interface, enables or disables interrupts, selects master or slave mode and transmission or reception, enables or disables acknowledgement, confirms the i 2 c bus interface bus status, issues start/stop conditions, and performs interrupt flag confirmation. iccr is initialized to h'01 by a reset and in hardware standby mode.
489 bit 7? 2 c bus interface enable (ice): selects whether or not the i 2 c bus interface is to be used. when ice is set to 1, port pins function as scl and sda input/output pins and transfer operations are enabled. when ice is cleared to 0, the i 2 c bus interface module is disabled and the internal state is cleared. the sar and sarx registers can be accessed when ice is 0. the icmr and icdr registers can be accessed when ice is 1. bit 7 ice description 0i 2 c bus interface module disabled, with scl and sda signal pins set to port?unction i 2 c bus interface module internal state initialized sar and sarx can be accessed (initial value) 1i 2 c bus interface module enabled for transfer operations (pins scl and sca are driving the bus) icmr and icdr can be accessed bit 6? 2 c bus interface interrupt enable (ieic): enables or disables interrupts from the i 2 c bus interface to the cpu. bit 6 ieic description 0 interrupts disabled (initial value) 1 interrupts enabled bit 5?aster/slave select (mst) bit 4?ransmit/receive select (trs) mst selects whether the i 2 c bus interface operates in master mode or slave mode. trs selects whether the i 2 c bus interface operates in transmit mode or receive mode. in master mode with the i 2 c bus format, when arbitration is lost, mst and trs are both reset by hardware, causing a transition to slave receive mode. in slave receive mode with the addressing format (fs = 0 or fsx = 0), hardware automatically selects transmit or receive mode according to the r/ w bit in the first frame after a start condition. modification of the trs bit during transfer is deferred until transfer of the frame containing the acknowledge bit is completed, and the changeover is made after completion of the transfer. mst and trs select the operating mode as follows.
490 bit 5 bit 4 mst trs operating mode 0 0 slave receive mode (initial value) 1 slave transmit mode 1 0 master receive mode 1 master transmit mode bit 5 mst description 0 slave mode [clearing conditions] 1. when 0 is written by software 2. when bus arbitration is lost after transmission is started in i 2 c bus format master mode (initial value) 1 master mode [setting conditions] 1. when 1 is written by software (in cases other than clearing condition 2) 2. when 1 is written in mst after reading mst = 0 (in case of clearing condition 2) bit 4 trs description 0 receive mode [clearing conditions] 1. when 0 is written by software (in cases other than setting condition 3) 2. when 0 is written in trs after reading trs = 1 (in case of clearing condition 3) 3. when bus arbitration is lost after transmission is started in i 2 c bus format master mode 4. when the sw bit in ddcswr changes from 1 to 0 (initial value) 1 transmit mode [setting conditions] 1. when 1 is written by software (in cases other than clearing conditions 3 and 4) 2. when 1 is written in trs after reading trs = 0 (in case of clearing conditions 3 and 4) 3. when a 1 is received as the r/w bit of the first frame in i 2 c bus format slave mode
491 bit 3?cknowledge bit judgement selection (acke): specifies whether the value of the acknowledge bit returned from the receiving device when using the i 2 c bus format is to be ignored and continuous transfer is performed, or transfer is to be aborted and error handling, etc., performed if the acknowledge bit is 1. when the acke bit is 0, the value of the received acknowledge bit is not indicated by the ackb bit, which is always 0. in the h8s/2169 or h8s/2149, the dtc can be used to perform continuous transfer. the dtc is activated when the irtr interrupt flag is set to 1 (irtr is one of two interrupt flags, the other being iric). when the acke bit is 0, the tdre, iric, and irtr flags are set on completion of data transmission, regardless of the value of the acknowledge bit. when the acke bit is 1, the tdre, iric, and irtr flags are set on completion of data transmission when the acknowledge bit is 0, and the iric flag alone is set on completion of data transmission when the acknowledge bit is 1. when the dtc is activated, the tdre, iric, and irtr flags are cleared to 0 after the specified number of data transfers have been executed. consequently, interrupts are not generated during continuous data transfer, but if data transmission is completed with a 1 acknowledge bit when the acke bit is set to 1, the dtc is not activated and an interrupt is generated, if enabled. depending on the receiving device, the acknowledge bit may be significant, in indicating completion of processing of the received data, for instance, or may be fixed at 1 and have no significance. bit 3 acke description 0 the value of the acknowledge bit is ignored, and continuous transfer is performed (initial value) 1 if the acknowledge bit is 1, continuous transfer is interrupted bit 2?us busy (bbsy): the bbsy flag can be read to check whether the i 2 c bus (scl, sda) is busy or free. in master mode, this bit is also used to issue start and stop conditions. a high-to-low transition of sda while scl is high is recognized as a start condition, setting bbsy to 1. a low-to-high transition of sda while scl is high is recognized as a stop condition, clearing bbsy to 0. to issue a start condition, use a mov instruction to write 1 in bbsy and 0 in scp. a retransmit start condition is issued in the same way. to issue a stop condition, use a mov instruction to write 0 in bbsy and 0 in scp. it is not possible to write to bbsy in slave mode; the i 2 c bus interface must be set to master transmit mode before issuing a start condition. mst and trs should both be set to 1 before writing 1 in bbsy and 0 in scp.
492 bit 2 bbsy description 0 bus is free [clearing condition] when a stop condition is detected (initial value) 1 bus is busy [setting condition] when a start condition is detected bit 1? 2 c bus interface interrupt request flag (iric): indicates that the i 2 c bus interface has issued an interrupt request to the cpu. iric is set to 1 at the end of a data transfer, when a slave address or general call address is detected in slave receive mode, when bus arbitration is lost in master transmit mode, and when a stop condition is detected. iric is set at different times depending on the fs bit in sar and the wait bit in icmr. see section 16.3.6, iric setting timing and scl control. the conditions under which iric is set also differ depending on the setting of the acke bit in iccr. iric is cleared by reading iric after it has been set to 1, then writing 0 in iric. when the dtc is used, iric is cleared automatically and transfer can be performed continuously without cpu intervention.
493 bit 1 iric description 0 waiting for transfer, or transfer in progress (initial value) [clearing conditions] 1. when 0 is written in iric after reading iric = 1 2. when icdr is written or read by the dtc (when the tdre or rdrf flag is cleared to 0) (this is not always a clearing condition; see the description of dtc operation for details) 1 interrupt requested [setting conditions] ? i 2 c bus format master mode 1. when a start condition is detected in the bus line state after a start condition is issued (when the tdre flag is set to 1 because of first frame transmission) 2. when a wait is inserted between the data and acknowledge bit when wait = 1 3. at the end of data transfer (when a wait is not inserted(wait=0), at the rise of the 9th transmit/receive clock pulse, or, when a wait is inserted(wait=1), at the fall of the 8th transmit/receive clock pulse) 4. when a slave address is received after bus arbitration is lost (when the al flag is set to 1) 5. when 1 is received as the acknowledge bit when the acke bit is 1 (when the ackb bit is set to 1) ? i 2 c bus format slave mode 1. when the slave address (sva, svax) matches (when the aas and aasx flags are set to 1) and at the end of data transfer up to the subsequent retransmission start condition or stop condition detection (when the tdre or rdrf flag is set to 1) 2. when the general call address is detected (when fs = 0 and the adz flag is set to 1) and at the end of data transfer up to the subsequent retransmission start condition or stop condition detection (when the tdre or rdrf flag is set to 1) 3. when 1 is received as the acknowledge bit when the acke bit is 1 (when the ackb bit is set to 1) 4. when a stop condition is detected (when the stop or estp flag is set to 1) ? synchronous serial format, and formatless mode 1. at the end of data transfer (when the tdre or rdrf flag is set to 1) 2. when a start condition is detected with serial format selected 3. when the sw bit is set to 1 in ddcswr when any other condition arises in which the tdre or rdrf flag is set to 1.
494 when, with the i 2 c bus format selected, iric is set to 1 and an interrupt is generated, other flags must be checked in order to identify the source that set iric to 1. although each source has a corresponding flag, caution is needed at the end of a transfer. when the tdre or rdrf internal flag is set, the readable irtr flag may or may not be set. the irtr flag (the dtc start request flag) is not set at the end of a data transfer up to detection of a retransmission start condition or stop condition after a slave address (sva) or general call address match in i 2 c bus format slave mode. even when the iric flag and irtr flag are set, the tdre or rdrf internal flag may not be set. the iric and irtr flags are not cleared at the end of the specified number of transfers in continuous transfer using the dtc. the tdre or rdrf flag is cleared, however, since the specified number of icdr reads or writes have been completed. table 16.3 shows the relationship between the flags and the transfer states. table 16.3 flags and transfer states mst trs bbsy estp stop irtr aasx al aas adz ackb state 1/01/0000000000 idle state (flag clearing required) 11000000000 start condition issuance 11100100000 start condition established 11/0100000000/1 master mode wait 11/0100100000/1 master mode transmit/receive end 0010001/011/01/00 arbitration lost 00100000100 sar match by first frame in slave mode 00100000110 general call address match 00100010000 sarx match 01/0100000000/1 slave mode transmit/receive end (except after sarx match) 0 0 1/0 1 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 slave mode transmit/receive end (after sarx match) 0 1/0 0 1/0 1/0 0 0 0 0 0 0/1 stop condition detected
495 bit 0?tart condition/stop condition prohibit (scp): controls the issuing of start and stop conditions in master mode. to issue a start condition, write 1 in bbsy and 0 in scp. a retransmit start condition is issued in the same way. to issue a stop condition, write 0 in bbsy and 0 in scp. this bit is always read as 1. if 1 is written, the data is not stored. bit 0 scp description 0 writing 0 issues a start or stop condition, in combination with the bbsy flag 1 reading always returns a value of 1 writing is ignored (initial value) 16.2.6 i 2 c bus status register (icsr) bit initial value read/write note: * only 0 can be written, to clear the flags. 7 estp 0 r/(w) * 6 stop 0 r/(w) * 5 irtr 0 r/(w) * 4 aasx 0 r/(w) * 3 al 0 r/(w) * 0 ackb 0 r/w 2 aas 0 r/(w) * 1 adz 0 r/(w) * icsr is an 8-bit readable/writable register that performs flag confirmation and acknowledge confirmation and control. icsr is initialized to h'00 by a reset and in hardware standby mode. bit 7?rror stop condition detection flag (estp): indicates that a stop condition has been detected during frame transfer in i 2 c bus format slave mode.
496 bit 7 estp description 0 no error stop condition [clearing conditions] 1. when 0 is written in estp after reading estp = 1 2. when the iric flag is cleared to 0 (initial value) 1 ? in i 2 c bus format slave mode error stop condition detected [setting condition] when a stop condition is detected during frame transfer ? in other modes no meaning bit 6?ormal stop condition detection flag (stop): indicates that a stop condition has been detected after completion of frame transfer in i 2 c bus format slave mode. bit 6 stop description 0 no normal stop condition [clearing conditions] 1. when 0 is written in stop after reading stop = 1 2. when the iric flag is cleared to 0 (initial value) 1 ? in i 2 c bus format slave mode normal stop condition detected [setting condition] when a stop condition is detected after completion of frame transfer ? in other modes no meaning bit 5? 2 c bus interface continuous transmission/reception interrupt request flag (irtr): indicates that the i 2 c bus interface has issued an interrupt request to the cpu, and the source is completion of reception/transmission of one frame in continuous transmission/reception for which dtc activation is possible. when the irtr flag is set to 1, the iric flag is also set to 1 at the same time. irtr flag setting is performed when the tdre or rdrf flag is set to 1. irtr is cleared by reading irtr after it has been set to 1, then writing 0 in irtr. irtr is also cleared automatically when the iric flag is cleared to 0.
497 bit 5 irtr description 0 waiting for transfer, or transfer in progress [clearing conditions] 1. when 0 is written in irtr after reading irtr = 1 2. when the iric flag is cleared to 0 (initial value) 1 continuous transfer state [setting condition] ? in i 2 c bus interface slave mode when the tdre or rdrf flag is set to 1 when aasx = 1 ? in other modes when the tdre or rdrf flag is set to 1 bit 4?econd slave address recognition flag (aasx): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition matches bits svax6 to svax0 in sarx. aasx is cleared by reading aasx after it has been set to 1, then writing 0 in aasx. aasx is also cleared automatically when a start condition is detected. bit 4 aasx description 0 second slave address not recognized [clearing conditions] 1. when 0 is written in aasx after reading aasx = 1 2. when a start condition is detected 3. in master mode (initial value) 1 second slave address recognized [setting condition] when the second slave address is detected in slave receive mode while fsx = 0 bit 3?rbitration lost (al): this flag indicates that arbitration was lost in master mode. the i 2 c bus interface monitors the bus. when two or more master devices attempt to seize the bus at nearly the same time, if the i 2 c bus interface detects data differing from the data it sent, it sets al to 1 to indicate that the bus has been taken by another master.
498 al is cleared by reading al after it has been set to 1, then writing 0 in al. in addition, al is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 3 al description 0 bus arbitration won [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in al after reading al = 1 (initial value) 1 arbitration lost [setting conditions] 1. if the internal sda and sda pin disagree at the rise of scl in master transmit mode 2. if the internal scl line is high at the fall of scl in master transmit mode bit 2?lave address recognition flag (aas): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition matches bits sva6 to sva0 in sar, or if the general call address (h'00) is detected. aas is cleared by reading aas after it has been set to 1, then writing 0 in aas. in addition, aas is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 2 aas description 0 slave address or general call address not recognized [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in aas after reading aas = 1 3. in master mode (initial value) 1 slave address or general call address recognized [setting condition] when the slave address or general call address is detected in slave receive mode while fs = 0
499 bit 1?eneral call address recognition flag (adz): in i 2 c bus format slave receive mode, this flag is set to 1 if the first frame following a start condition is the general call address (h'00). adz is cleared by reading adz after it has been set to 1, then writing 0 in adz. in addition, adz is reset automatically by write access to icdr in transmit mode, or read access to icdr in receive mode. bit 1 adz description 0 general call address not recognized [clearing conditions] 1. when icdr data is written (transmit mode) or read (receive mode) 2. when 0 is written in adz after reading adz = 1 3. in master mode (initial value) 1 general call address recognized [setting condition] when the general call address is detected in slave receive mode while fsx = 0 or fs = 0 bit 0?cknowledge bit (ackb): stores acknowledge data. in transmit mode, after the receiving device receives data, it returns acknowledge data, and this data is loaded into ackb. in receive mode, after data has been received, the acknowledge data set in this bit is sent to the transmitting device. when this bit is read, in transmission (when trs = 1), the value loaded from the bus line (returned by the receiving device) is read. in reception (when trs = 0), the value set by internal software is read. when writing to this bit, acknowledge data that is returned after receiving is rewritten regardless of the trs value. the data loaded from receiving device is retained, therefore pay attention when using bit-manipulation instructions. bit 0 ackb description 0 receive mode: 0 is output at acknowledge output timing (initial value) transmit mode: indicates that the receiving device has acknowledged the data (signal is 0) 1 receive mode: 1 is output at acknowledge output timing transmit mode: indicates that the receiving device has not acknowledged the data (signal is 1)
500 16.2.7 serial/timer control register (stcr) bit initial value read/write 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 0 r/w 1 icks1 0 r/w stcr is an 8-bit readable/writable register that controls register access, the i 2 c interface operating mode (when the on-chip iic option is included), and on-chip flash memory, and selects the tcnt input clock source. for details of functions not related to the i 2 c bus interface, see section 3.2.4, serial/timer control register (stcr), and the descriptions of the relevant modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bit 7? 2 c extra buffer select (iics): designates bits 7 to 4 of port a as the same kind of output buffer as scl and sda. this bit is used when implementing the i 2 c interface by software only. bit 7 iics description 0 pa7 to pa4 are normal i/o pins (initial value) 1 pa7 to pa4 are i/o pins with bus driving capability bit 6? 2 c transfer select 1 (iicx1): this bit, together with bits cks2 to cks0 in icmr of iic1, selects the transfer rate in master mode. for details, see section 16.2.4, i 2 c bus mode register (icmr). bit 5? 2 c transfer select 0 (iicx0): this bit, together with bits cks2 to cks0 in icmr of iic0, selects the transfer rate in master mode. for details, see section 16.2.4, i 2 c bus mode register (icmr). bit 4? 2 c master enable (iice): controls cpu access to the i 2 c bus interface data and control registers (iccr, icsr, icdr/sarx, icmr/sar). bit 4 iice description 0 cpu access to i 2 c bus interface data and control registers is disabled (initial value) 1 cpu access to i 2 c bus interface data and control registers is enabled
501 bit 3?lash memory control register enable (flshe): controls the access of cpu to the flash memory control registers, the power-down mode control registers, and the supporting module control registers. see section 3.2.4, serial/timer control register (stcr). bit 2?eserved: do not write 1 to this bit. bits 1 and 0?nternal clock source select 1 and 0 (icks1, icsk0): these bits, together with bits cks2 to cks0 in tcr, select the clock input to the timer counters (tcnt). for details, see section 12.2.4, timer control register (tcr). 16.2.8 ddc switch register (ddcswr) bit initial value read/write notes: 1. only 0 can be written, to clear the flag. 2. always read as 1. 7 swe 0 r/w 6 sw 0 r/w 5 ie 0 r/w 4 if 0 r/(w) * 1 3 clr3 1 w * 2 0 clr0 1 w * 2 2 clr2 1 w * 2 1 clr1 1 w * 2 ddcswr is an 8-bit readable/writable register that controls the iic channel 0 automatic format switching function and iic internal latch clearance. ddcswr is initialized to h'0f by a reset and in hardware standby mode. bit 7?dc mode switch enable (swe): selects the function for automatically switching iic channel 0 from formatless mode to the i 2 c bus format. bit 7 swe description 0 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is disabled (initial value) 1 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is enabled bit 6?dc mode switch (sw): selects either formatless mode or the i 2 c bus format for iic channel 0.
502 bit 6 sw description 0 iic channel 0 is used with the i 2 c bus format [clearing conditions] 1. when 0 is written by software 2. when a falling edge is detected on the scl pin when swe = 1 (initial value) 1 iic channel 0 is used in formatless mode [setting condition] when 1 is written in sw after reading sw = 0 bit 5?dc mode switch interrupt enable bit (ie): enables or disables an interrupt request to the cpu when automatic format switching is executed for iic channel 0. bit 5 ie description 0 interrupt when automatic format switching is executed is disabled (initial value) 1 interrupt when automatic format switching is executed is enabled bit 4?dc mode switch interrupt flag (if): flag that indicates an interrupt request to the cpu when automatic format switching is executed for iic channel 0. bit 4 if description 0 no interrupt is requested when automatic format switching is executed [clearing condition] when 0 is written in if after reading if = 1 (initial value) 1 an interrupt is requested when automatic format switching is executed [setting condition] when a falling edge is detected on the scl pin when swe = 1 bits 3 to 0?ic clear 3 to 0 (clr3 to clr0): these bits control initialization of the internal state of iic0 and iic1. these bits can only be written to; if read they will always return a value of 1. when a write operation is performed on these bits, a clear signal is generated for the internal latch circuit of the corresponding module(s), and the internal state of the iic module(s) is initialized.
503 the write data for these bits is not retained. to perform iic clearance, bits clr3 to clr0 must be written to simultaneously using an mov instruction. do not use a bit manipulation instruction such as bclr. when clearing is required again, all the bits must be written to in accordance with the setting. bit 3 bit 2 bit 1 bit 0 clr3 clr2 clr1 clr0 description 0 0 setting prohibited 1 0 0 setting prohibited 1 iic0 internal latch cleared 1 0 iic1 internal latch cleared 1 iic0 and iic1 internal latches cleared 1 invalid setting 16.2.9 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers, and is used to perform module stop mode control. when the mstp4 or mstp3 bit is set to 1, operation of the corresponding iic channel is halted at the end of the bus cycle, and a transition is made to module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode.
504 mstpcrl bit 4?odule stop (mstp4): specifies iic channel 0 module stop mode. mstpcrl bit 4 mstp4 description 0 iic channel 0 module stop mode is cleared 1 iic channel 0 module stop mode is set (initial value) mstpcrl bit 3?odule stop (mstp3): specifies iic channel 1 module stop mode. mstpcrl bit 3 mstp3 description 0 iic channel 1 module stop mode is cleared 1 iic channel 1 module stop mode is set (initial value) 16.3 operation 16.3.1 i 2 c bus data format the i 2 c bus interface has serial and i 2 c bus formats. the i 2 c bus formats are addressing formats with an acknowledge bit. these are shown in figures 16.3 (a) and (b). the first frame following a start condition always consists of 8 bits. iic channel 0 only is capable of formatless operation, as shown in figure 16.4. the serial format is a non-addressing format with no acknowledge bit. this is shown in figure 16.5. figure 16.6 shows the i 2 c bus timing. the symbols used in figures 16.3 to 16.6 are explained in table 16.4.
505 s sla r/ w a data a a/ a p 1111 n 7 1 m (a) i 2 c bus format (fs = 0 or fsx = 0) (b) i 2 c bus format (start condition retransmission, fs = 0 or fsx = 0) transfer bit count (n = 1 to 8) transfer frame count (m 3 1) s sla r/ w a data 111 n1 7 1 m1 s sla r/ w a data a/ a p 111 n2 7 1 m2 11 1 a/ a transfer bit count (n1 and n2 = 1 to 8) transfer frame count (m1 and m2 3 1) 11 figure 16.3 i 2 c bus data formats (i 2 c bus formats) iic0 only, fs = 0 or fsx = 0 data a a data 11 n 8 1 m 1 a/ a transfer bit count (n = 1 to 8) transfer frame count (m 3 1) note: this mode applies to the ddc (display data channel) which is a pc monitoring system standard. figure 16.4 formatless s data data p 11 n 8 1 m fs = 1 and fsx = 1 transfer bit count (n = 1 to 8) transfer frame count (m 3 1) figure 16.5 i 2 c bus data format (serial format)
506 sda scl s 1-7 sla 8 r/ w 9 a 1-7 data 8 9 1-7 8 9 a data p a/ a figure 16.6 i 2 c bus timing table 16.4 i 2 c bus data format symbols legend s start condition. the master device drives sda from high to low while scl is high sla slave address, by which the master device selects a slave device r/ w indicates the direction of data transfer: from the slave device to the master device when r/ w is 1, or from the master device to the slave device when r/ w is 0 a acknowledge. the receiving device (the slave in master transmit mode, or the master in master receive mode) drives sda low to acknowledge a transfer data transferred data. the bit length is set by bits bc2 to bc0 in icmr. the msb-first or lsb-first format is selected by bit mls in icmr p stop condition. the master device drives sda from low to high while scl is high 16.3.2 master transmit operation in i 2 c bus format master transmit mode, the master device outputs the transmit clock and transmit data, and the slave device returns an acknowledge signal. the transmission procedure and operations by which data is sequentially transmitted in synchronization with icdr write operations, are described below. [1] set the ice bit in iccr to 1. set bits mls, wait, and cks2 to cks0 in icmr, and bit iicx in stcr, according to the operation mode. [2] read the bbsy flag to confirm that the bus is free. [3] set the mst and trs bits to 1 in iccr to select master transmit mode. [4] write 1 to bbsy and 0 to scp. this switches sda from high to low when scl is high, and generates the start condition. [5] when the start condition is generated, the iric and irtr flags are set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. [6] write data to icdr (slave address + r/ w )
507 with the i 2 c bus format (when the fs bit in sar or the fsx bit in sarx is 0), the first framedata following the start condition indicates the 7-bit slave address and transmit/receive direction. then clear the iric flag to indicate the end of transfer.writing to icdr and clearing of the iric flag must be executed continuously, so that no interrupt is inserted. if a period of time that is equal to transfer one byte has elapsed by the time the iric flag is cleared, the end of transfer cannot be identified. the master device sequentially sends the transmit clock and the data written to icdr with the timing shown in figure 16.7. the selected slave device (i.e., the slave device with the matching slave address) drives sda low at the 9th transmit clock pulse and returns an acknowledge signal. [7] when one frame of data has been transmitted, the iric flag is set to 1 at the rise of the 9th transmit clock pulse. after one frame has been transmitted, scl is automatically fixed low in synchronization with the internal clock until the next transmit data is written. [8] read the ackb bit to confirm that ackb is 0. when the slave device has not returned an acknowledge signal and ackb remains 1, execute the transmit end processing described in step [12] and perform transmit operation again. [9] write the next data to be transmitted in icdr. to identify the end of data transfer, clear the iric flag to 0. as described in step [6] above, writing to icdr and clearing of the iric flag must be executed continuously so that no interrupt is inserted. the next frame is transmitted in synchronization with the internal clock. [10] when one frame of data has been transmitted, the iric flag is set to 1 at the rise of the 9th transmit clock pulse. after one frame has been transmitted, scl is automatically fixed low in synchronization with the internal clock until the next transmit data is written. [11] read the ackb bit of icsr. confirm that the slave device has returned an acknowledge signal and ackb is 0. when more data is to be transmitted, return to step [9] to execute next transmit operation. if the slave device has not returned an acknowledge signal and ackb is 1, execute the transmit end processing described in step [12]. [12] clear the iric flag to 0. write bbsy and csp of iccr to 0. by doing so, sda is changed from low to high while scl is high and the transmit stop condition is generated.
508 sda (master output) sda (slave output) 2 1 r/ w 4 36 58 7 12 9 a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 bit 6 iric irtr icdr normal operation precaution: data set timing to icdr incorrect operation scl (master output) start condition generation slave address data 1 data 1 [9] icdr write [9] iric clear [6] icdr write [6] iric clear [4] write 1 to bbsy and 0 to scp (start condition issuance ) user processing address + r/ w [7] [5] (icdr writing prohibited) figure 16.7 example of master transmit mode operating timing (mls = wait = 0) 16.3.3 master receive operation in master receive mode, the master device outputs the receive clock, receives data, and returns an acknowledge signal. the slave device transmits data. the receive procedure and operations by which data is sequentially received in synchronization with icdr read operations, are described below. [1] clear the trs bit of iccr to 0 and switch from transmit mode to receive mode. set the wait bit to 1 and clear the ackb bit of icsr to 0 (acknowledge data setting). [2] when icdr is read (dummy data read), reception is started and the receive clock is output, and data is received, in synchronization with the internal clock. to indicate the wait, clear the iric flag to 0. reading from icdr and clearing of the iric flag must be executed continuously so that no interrupt is inserted. if a period of time that is equal to transfer one byte has elapsed by the time the iric flag is cleared, the end of transfer cannot be identified. [3] the iric flag is set to 1 at the fall of the 8th clock of a one-frame reception clock. at this point, if the ieic bit of iccr is set to 1, an interrupt request is generated to the cpu.
509 scl is automatically fixed low in synchronization with the internal clock until the iric flag is cleared. if the first frame is the final reception frame, execute the end processing as described in [10]. [4] clear the iric flag to 0 to release from the wait state. the master device outputs the 9th receive clock pulse, sets sda to low, and returns an acknowledge signal. [5] when one frame of data has been transmitted, the iric and irtr flags are set to 1 at the rise of the 9th transmit clock pulse. the master device continues to output the receive clock for the next receive data. [6] read the icdr receive data. [7] clear the iric flag to indicate the next wait. from clearing of the iric flag to completion of data transmission as described in steps [5], [6], and [7], must be performed within the time taken to transfer one byte because releasing of the wait state as described in step [4](or[9]). [8] the iric flag is set to 1 at the fall of the 8th receive clock pulse. scl is automatically fixed low in synchronization with the internal clock until the iric flag is cleared. if this frame is the final reception frame, execute the end processing as described in [10]. [9] clear the iric flag to 0 to release from the wait state. the master device outputs the 9th reception clock pulse, sets sda to low, and returns an acknowledge signal. by repeating steps [5] to [9] above, more data can be received. [10] set the ackb bit of icsr to 1 and set the acknowledge data for the final reception. set the trs bit of iccr to 1 to change receive mode to transmit mode. [11] clear the iric flag to release from the wait state. [12] when one frame of data has been received, the iric flag is set to 1 at the rise of the 9th reception clock pulse. [13] clear the wait bit of icmr to 0 to cancel wait mode. read the icdr receive data and clear the iric flag to 0. clear the iric flag only when wait = 0. (if the stop-condition generation command is executed after clearing the iric flag to 0 and then clearing the wait bit to 0, the sda line is fixed low and the stop condition cannot be generated.) [14] write 0 to bbsy and scp. this changes sda from low to high when scl is high, and generates the stop condition.
510 sda (master output) sda (slave output) 2 14 3 6 5 8 7 1 2345 9 9 a a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 bit 6 bit 5 bit 4 bit 3 iric irtr icdr scl (master output) master transmit mode master receive mode data 1 data 1 data 2 [2] icdr read (dummy read) [1] trs = 0 clear wait = 1 set ackb = 0 clear [2] iric clear [7] iric clear [6] icdr read (data 1) [4] iric clear user processing [5] [3] figure 16.8 (1) example of master receive mode operating timing (mls = ackb = 0 and wait = 1) sda (master output) sda (slave output) 2 14 3 6 5 8 7 1 2 9 9 8 a a bit 7 bit 0 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 bit 6 iric irtr icdr scl (master output) data 3 data 2 data 1 data 2 data 3 data 4 [9] iric clear [7] iric clear [9] iric clear [7] iric clear user processing [5] [8] [5] [8] [6] icdr read (data 2) [6] icdr read (data 3) figure 16.8 (2) example of master receive mode operating timing (mls = ackb = 0 and wait = 1)
511 16.3.4 slave receive operation in slave receive mode, the master device outputs the transmit clock and transmit data, and the slave device returns an acknowledge signal. the reception procedure and operations in slave receive mode are described below. [1] set the ice bit in iccr to 1. set the mls bit in icmr and the mst and trs bits in iccr according to the operating mode. [2] when the start condition output by the master device is detected, the bbsy flag in iccr is set to 1. [3] when the slave address matches in the first frame following the start condition, the device operates as the slave device specified by the master device. if the 8th data bit (r/ w ) is 0, the trs bit in iccr remains cleared to 0, and slave receive operation is performed. [4] at the 9th clock pulse of the receive frame, the slave device drives sda low and returns an acknowledge signal. at the same time, the iric flag in iccr is set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. if the rdrf internal flag has been cleared to 0, it is set to 1, and the receive operation continues. if the rdrf internal flag has been set to 1, the slave device drives scl low from the fall of the receive clock until data is read into icdr. [5] read icdr and clear the iric flag in iccr to 0. the rdrf flag is cleared to 0. receive operations can be performed continuously by repeating steps [4] and [5]. when sda is changed from low to high when scl is high, and the stop condition is detected, the bbsy flag in iccr is cleared to 0.
512 sda (master output) sda (slave output) 2 1 2 1 4 36 58 79 bit 7 bit 6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrs icdrr rdrf scl (master output) start condition generation scl (slave output) interrupt request generation address + r/ w address + r/ w [5] icdr read [5] iric clearance user processing slave address data 1 [4] a r/ w figure 16.9 example of slave receive mode operation timing (1) (mls = ackb = 0)
513 sda (master output) sda (slave output) 2 14 36 58 79 8 79 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 1 bit 0 iric icdrs icdrr rdrf scl (master output) scl (slave output) interrupt request generation interrupt request generation data 2 data 2 data 1 data 1 [5] icdr read [5] iric clearance user processing data 2 data 1 [4] [4] a a figure 16.10 example of slave receive mode operation timing (2) (mls = ackb = 0) 16.3.5 slave transmit operation in slave transmit mode, the slave device outputs the transmit data, while the master device outputs the receive clock and returns an acknowledge signal. the transmission procedure and operations in slave transmit mode are described below. [1] set the ice bit in iccr to 1. set the mls bit in icmr and the mst and trs bits in iccr according to the operating mode. [2] when the slave address matches in the first frame following detection of the start condition, the slave device drives sda low at the 9th clock pulse and returns an acknowledge signal. at the same time, the iric flag in iccr is set to 1. if the ieic bit in iccr has been set to 1, an interrupt request is sent to the cpu. .if the 8th data bit (r/ w ) is 1, the trs bit in iccr is set to 1, and the mode changes to slave transmit mode automatically. the tdre internal flag is set to 1. the slave device drives scl low from the fall of the transmit clock until icdr data is written. [3] after clearing the iric flag to 0, write data to icdr. the tdre internal flag is cleared to 0. the written data is transferred to icdrs, and the tdre internal flag and the iric and irtr
514 flags are set to 1 again. after clearing the iric flag to 0, write the next data to icdr. the slave device sequentially sends the data written into icdr in accordance with the clock output by the master device at the timing shown in figure 16.10. [4] when one frame of data has been transmitted, the iric flag in iccr is set to 1 at the rise of the 9th transmit clock pulse. if the tdre internal flag has been set to 1, this slave device drives scl low from the fall of the transmit clock until data is written to icdr. the master device drives sda low at the 9th clock pulse, and returns an acknowledge signal. as this acknowledge signal is stored in the ackb bit in icsr, this bit can be used to determine whether the transfer operation was performed normally. when the tdre internal flag is 0, the data written into icdr is transferred to icdrs, transmission is started, and the tdre internal flag and the iric and irtr flags are set to 1 again. [5] to continue transmission, clear the iric flag to 0, then write the next data to be transmitted into icdr. the tdre flag is cleared to 0. transmit operations can be performed continuously by repeating steps [4] and [5]. to end transmission, write h'ff to icdr to release sda on the slave side. when sda is changed from low to high when scl is high, and the stop condition is detected, the bbsy flag in iccr is cleared to 0.
515 sda (slave output) sda (master output) scl (slave output) 2 1 2 1 4 36 58 79 9 8 bit 7 bit 6 bit 5 bit 7 bit 6 bit 4 bit 3 bit 2 bit 1 bit 0 iric icdrs icdrt tdre scl (master output) interrupt request generation interrupt request generation slave receive mode slave transmit mode data 1 data 2 [3] iric clearance [5] iric clearance [3] icdr write [3] icdr write [5] icdr write user processing data 1 data 1 data 2 data 2 a r/ w a [3] [2] interrupt request generation figure 16.11 example of slave transmit mode operation timing (mls = 0) 16.3.6 iric setting timing and scl control the interrupt request flag (iric) is set at different times depending on the wait bit in icmr, the fs bit in sar, and the fsx bit in sarx. if the tdre or rdrf internal flag is set to 1, scl is automatically held low after one frame has been transferred; this timing is synchronized with the internal clock. figure 16.11 shows the iric set timing and scl control.
516 (a) when wait = 0, and fs = 0 or fsx = 0 (i 2 c bus format, no wait) scl sda iric user processing clear iric write to icdr (transmit) or read icdr (receive) 1 a 8 1 1 a 7 1 89 7 (b) when wait = 1, and fs = 0 or fsx = 0 (i 2 c bus format, wait inserted) scl sda iric user processing clear iric clear iric write to icdr (transmit) or read icdr (receive) scl sda iric user processing (c) when fs = 1 and fsx = 1 (synchronous serial format) clear iric write to icdr (transmit) or read icdr (receive) 8 89 8 7 1 8 7 1 figure 16.12 iric setting timing and scl control 16.3.7 automatic switching from formatless mode to i 2 c bus format setting the sw bit to 1 in ddcswr enables formatless mode to be selected as the iic0 operating mode. switching from formatless mode to the i 2 c bus format (slave mode) is performed automatically when a falling edge is detected on the scl pin. the following four preconditions are necessary for this operation:
517 ? a common data pin (sda) for formatless and i 2 c bus format operation ? separate clock pins for formatless operation (vsynci) and i 2 c bus format operation (scl) ? a fixed 1 level for the scl pin during formatless operation (the scl pin does not output a low level) ? settings of bits other than trs in iccr that allow i 2 c bus format operation automatic switching is performed from formatless mode to the i 2 c bus format when the sw bit in ddcswr is automatically cleared to 0 on detection of a falling edge on the scl pin. switching from the i 2 c bus format to formatless mode is achieved by having software set the sw bit in ddcswr to 1. in formatless mode, bits (such as msl and trs) that control the i 2 c bus interface operating mode must not be modified. when switching from the i 2 c bus format to formatless mode, set the trs bit to 1 or clear it to 0 according to the transmit data (transmission or reception) in formatless mode, then set the sw bit to 1. after automatic switching from formatless mode to the i 2 c bus format (slave mode), in order to wait for slave address reception, the trs bit is automatically cleared to 0. if a falling edge is detected on the scl pin during formatless operation, i 2 c bus interface operation is deferred until a stop condition is detected.
518 16.3.8 operation using the dtc the i 2 c bus format provides for selection of the slave device and transfer direction by means of the slave address and the r/ w bit, confirmation of reception with the acknowledge bit, indication of the last frame, and so on. therefore, continuous data transfer using the dtc must be carried out in conjunction with cpu processing by means of interrupts. table 16.5 shows some examples of processing using the dtc. these examples assume that the number of transfer data bytes is known in slave mode. table 16.5 examples of operation using the dtc item master transmit mode master receive mode slave transmit mode slave receive mode slave address + r/ w bit transmission/ reception transmission by dtc (icdr write) transmission by cpu (icdr write) reception by cpu (icdr read) reception by cpu (icdr read) dummy data read processing by cpu (icdr read) actual data transmission/ reception transmission by dtc (icdr write) reception by dtc (icdr read) transmission by dtc (icdr write) reception by dtc (icdr read) dummy data (h'ff) write processing by dtc (icdr write) last frame processing not necessary reception by cpu (icdr read) not necessary reception by cpu (icdr read) transfer request processing after last frame processing 1st time: clearing by cpu 2nd time: end condition issuance by cpu not necessary automatic clearing on detection of end condition during transmission of dummy data (h'ff) not necessary setting of number of dtc transfer data frames transmission: actual data count + 1 (+1 equivalent to slave address + r/ w bits) reception: actual data count transmission: actual data count + 1 (+1 equivalent to dummy data (h'ff)) reception: actual data count
519 16.3.9 noise canceler the logic levels at the scl and sda pins are routed through noise cancelers before being latched internally. figure 16.12 shows a block diagram of the noise canceler circuit. the noise canceler consists of two cascaded latches and a match detector. the scl (or sda) input signal is sampled on the system clock, but is not passed forward to the next circuit unless the outputs of both latches agree. if they do not agree, the previous value is held. system clock period sampling clock c dq latch c dq latch scl or sda input signal match detector internal scl or sda signal sampling clock figure 16.13 block diagram of noise canceler 16.3.10 sample flowcharts figures 16.13 to 16.16 show sample flowcharts for using the i 2 c bus interface in each mode.
520 start end initialize read bbsy in iccr read iric in iccr read iric in iccr read ackb in icsr write transmit data in icdr clear iric in iccr read ackb in icsr clear iric in iccr clear iric in iccr read iric in iccr write transmit data in icdr master receive mode set mst = 1 and trs = 1 in iccr write bbsy = 0 and scp = 0 in iccr write bbsy = 1 and scp = 0 in iccr bbsy = 0 ? no iric = 1 ? ackb = 0 ? no no yes yes iric = 1 ? no yes yes transmit mode ? iric = 1 ? end of transmission ? or ackb = 1 ? no no no yes yes yes [2] test the status of the scl and sda lines. [3] select master transmit mode. [4] start condition issuance [6] set transmit data for the first byte (slave address + r/ w ). (after writing icdr, clear iric immediately) [1] initialize [8] test the acknowledge bit, transferred from slave device. [5] wait for a start condition [7] wait for 1 byte to be transmitted. [10] wait for 1 byte to be transmitted. [11] test for end of transfer [12] stop condition issuance [9] set transmit data for the second and subsequent bytes. (after writing icdr, clear iric immediately.) figure 16.14 flowchart for master transmit mode (example)
521 end set trs = 0 in iccr set ackb = 1 in icsr set wait = 0 in icmr read iric in iccr clear iric in iccr clear iric in iccr clear iric in iccr read icdr clear iric in iccr set ackb = 0 in icsr set wait = 1 in icmr write bbsy = 0 and scp = 0 in iccr last receive ? iric = 1 ? no no yes last receive ? no yes yes read iric in iccr iric = 1 ? no yes read iric in iccr iric = 1 ? no yes set trs = 1 in iccr read icdr read icdr clear iric in iccr clear iric in iccr [4] clear iric to trigger the 9th clock. (to end the wait insertion) [7] clear iric. [1] select receive mode. [2] start receiving. the first read is a dummy read. after reading icdr, please clear iric immediately. [3] wait for 1 byte to be received (8th clock falling edge) [9] clear iric to trigger the 9th clock. (to end the wait insertion) [10] set ackb = 1 so as to return no acknowledge, or set trs = 1 so as not to issue extra clock. [11] clear iric to trigger the 9th clock (to end the wait insertion) [5] wait for 1 byte to be received. (9th clock rising edge) [8] wait for the next data to be received. (8th clock falling edge) [6] read the receive data. [13] set wait = 0. read icdr. clear iric. (note: after setting wait = 0, iric should be cleared to 0.) [14] stop condition issuance. master receive operation read iric in iccr iric = 1 ? no yes [12] wait for 1 byte to be received. figure 16.15 flowchart for master receive mode (example)
522 start initialize set mst = 0 and trs = 0 in iccr set ackb = 0 in icsr read iric in iccr iric = 1? yes no clear iric in iccr read aas and adz in icsr aas = 1 and adz = 0? read trs in iccr trs = 0? no yes no yes yes no yes yes no no [1] [2] [3] [4] [5] [6] [7] [8] last receive? read icdr read iric in iccr iric = 1? clear iric in iccr set ackb = 1 in icsr read icdr read iric in iccr read icdr iric = 1? clear iric in iccr end general call address processing * description omitted slave transmit mode [1] select slave receive mode. [2] wait for the first byte to be received (slave address). [3] start receiving. the first read is a dummy read. [4] wait for the transfer to end. [5] set acknowledge data for the last receive. [6] start the last receive. [7] wait for the transfer to end. [8] read the last receive data. figure 16.16 flowchart for slave receive mode (example)
523 slave transmit mode write transmit data in icdr read iric in iccr iric = 1? clear iric in iccr clear iric in iccr clear iric in iccr read ackb in icsr set trs = 0 in iccr end of transmission (ackb = 1)? yes no no yes end [1] [2] [3] read icdr [5] [4] [1] set transmit data for the second and subsequent bytes. [2] wait for 1 byte to be transmitted. [3] test for end of transfer. [4] select slave receive mode. [5] dummy read (to release the scl line). figure 16.17 flowchart for slave transmit mode (example) 16.3.11 initialization of internal state the iic has a function for forcible initialization of its internal state if a deadlock occurs during communication. initialization is executed in accordance with the setting of bits clr3 to clr0 in the ddcswr register or clearing ice bit. for details the setting of bits clr3 to clr0, see section 16.2.8, ddc switch register (ddcswr). scope of initialization: the initialization executed by this function covers the following items: ? tdre and rdrf internal flags ? transmit/receive sequencer and internal operating clock counter
524 ? internal latches for retaining the output state of the scl and sda pins (wait, clock, data output, etc.) the following items are not initialized: ? actual register values (icdr, sar, sarx, icmr, iccr, icsr, ddcswr, stcr) ? internal latches used to retain register read information for setting/clearing flags in the icmr, iccr, icsr, and ddcswr registers ? the value of the icmr register bit counter (bc2 to bc0) ? generated interrupt sources (interrupt sources transferred to the interrupt controller) notes on initialization: ? interrupt flags and interrupt sources are not cleared, and so flag clearing measures must be taken as necessary. ? basically, other register flags are not cleared either, and so flag clearing measures must be taken as necessary. ? when initialization is executed by the ddcswr register, the write data for bits clr3 to clr0 is not retained. to perform iic clearance, bits clr3 to clr0 must be written to simultaneously using an mov instruction. do not use a bit manipulation instruction such as bclr. similarly, when clearing is required again, all the bits must be written to simultaneously in accordance with the setting. ? if a flag clearing setting is made during transmission/reception, the iic module will stop transmitting/receiving at that point and the scl and sda pins will be released. when transmission/reception is started again, register initialization, etc., must be carried out as necessary to enable correct communication as a system. the value of the bbsy bit cannot be modified directly by this module clear function, but since the stop condition pin waveform is generated according to the state and release timing of the scl and sda pins, the bbsy bit may be cleared as a result. similarly, state switching of other bits and flags may also have an effect. to prevent problems caused by these factors, the following procedure should be used when initializing the iic state. 1. execute initialization of the internal state according to the setting of bits clr3 to clr0 or ice bit clearing. 2. execute a stop condition issuance instruction (write 0 to bbsy and scp) to clear the bbsy bit to 0, and wait for two transfer rate clock cycles. 3. re-execute initialization of the internal state according to the setting of bits clr3 to clr0 or ice bit clearing. 4. initialize (re-set) the iic registers.
525 16.4 usage notes ? in master mode, if an instruction to generate a start condition is immediately followed by an instruction to generate a stop condition, neither condition will be output correctly. to output consecutive start and stop conditions, after issuing the instruction that generates the start condition, read the relevant ports, check that scl and sda are both low, then issue the instruction that generates the stop condition. note that scl may not yet have gone low when bbsy is cleared to 0. ? either of the following two conditions will start the next transfer. pay attention to these conditions when reading or writing to icdr. ? write access to icdr when ice = 1 and trs = 1 (including automatic transfer from icdrt to icdrs) ? read access to icdr when ice = 1 and trs = 0 (including automatic transfer from icdrs to icdrr) ? table 16.6 shows the timing of scl and sda output in synchronization with the internal clock. timings on the bus are determined by the rise and fall times of signals affected by the bus load capacitance, series resistance, and parallel resistance. table 16.6 i 2 c bus timing (scl and sda output) item symbol output timing unit notes scl output cycle time t sclo 28t cyc to 256t cyc ns figure 25.27 scl output high pulse width t sclho 0.5t sclo ns (reference) scl output low pulse width t scllo 0.5t sclo ns sda output bus free time t bufo 0.5t sclo ?1t cyc ns start condition output hold time t staho 0.5t sclo ?1t cyc ns retransmission start condition output setup time t staso 1t sclo ns stop condition output setup time t stoso 0.5t sclo + 2t cyc ns data output setup time (master) t sdaso 1t scllo ?3t cyc ns data output setup time (slave) 1t scll ?(6t cyc or 12t cyc * ) data output hold time t sdaho 3t cyc ns note: * 6t cyc when iicx is 0, 12t cyc when 1. ? scl and sda input is sampled in synchronization with the internal clock. the ac timing therefore depends on the system clock cycle t cyc , as shown in i 2 c bus timing in section 25, electrical characteristics. note that the i 2 c bus interface ac timing specifications will not be met with a system clock frequency of less than 5 mhz.
526 ? the i 2 c bus interface specification for the scl rise time t sr is under 1000 ns (300 ns for high- speed mode). in master mode, the i 2 c bus interface monitors the scl line and synchronizes one bit at a time during communication. if t sr (the time for scl to go from low to v ih ) exceeds the time determined by the input clock of the i 2 c bus interface, the high period of scl is extended. the scl rise time is determined by the pull-up resistance and load capacitance of the scl line. to insure proper operation at the set transfer rate, adjust the pull-up resistance and load capacitance so that the scl rise time does not exceed the values given in the table below. table 16.7 permissible scl rise time (t sr ) values time indication iicx t cyc indication i 2 c bus specification (max.) ?= 5 mhz ?= 8 mhz ?= 10 mhz 0 7.5t cyc normal mode 1000 ns 1000 ns 937 ns 750 ns high-speed mode 300 ns 300 ns 300 ns 300 ns 1 17.5t cyc normal mode 1000 ns 1000 ns 1000 ns 1000 ns high-speed mode 300 ns 300 ns 300 ns 300 ns note: the maximum operating frequency for the h8s/2169 and h8s/2149 is 10 mhz. ? the i 2 c bus interface specifications for the scl and sda rise and fall times are under 1000 ns and 300 ns. the i 2 c bus interface scl and sda output timing is prescribed by t cyc , as shown in table 16.6. however, because of the rise and fall times, the i 2 c bus interface specifications may not be satisfied at the maximum transfer rate. table 16.8 shows output timing calculations for different operating frequencies, including the worst-case influence of rise and fall times. t bufo fails to meet the i 2 c bus interface specifications at any frequency. the solution is either (a) to provide coding to secure the necessary interval (approximately 1 m s) between issuance of a stop condition and issuance of a start condition, or (b) to select devices whose input timing permits this output timing for use as slave devices connected to the i 2 c bus. t scllo in high-speed mode and t staso in standard mode fail to satisfy the i 2 c bus interface specifications for worst-case calculations of t sr /t sf . possible solutions that should be investigated include (a) adjusting the rise and fall times by means of a pull-up resistor and capacitive load, (b) reducing the transfer rate to meet the specifications, or (c) selecting devices whose input timing permits this output timing for use as slave devices connected to the i 2 c bus.
527 table 16.8 i 2 c bus timing (with maximum influence of t sr /t sf ) time indication (at maximum transfer rate) [ns] item t cyc indication t sr /t sf influence (max.) i 2 c bus specification (min.) ?= 5 mhz ?= 8 mhz ?= 10 mhz t sclho 0.5t sclo standard mode ?000 4000 4000 4000 4000 (? sr ) high-speed mode ?00 600 950 950 950 t scllo 0.5t sclo standard mode ?50 4700 4750 4750 4750 (? sf ) high-speed mode ?50 1300 1000 * 1 1000 * 1 1000 * 1 t bufo 0.5t sclo standard mode ?000 4700 3800 * 1 3875 * 1 3900 * 1 1t cyc ( ? sr ) high-speed mode ?00 1300 750 * 1 825 * 1 850 * 1 t staho 0.5t sclo standard mode ?50 4000 4550 4625 4650 1t cyc (? sf ) high-speed mode ?50 600 800 875 900 t staso 1t sclo standard mode ?000 4700 9000 9000 9000 (? sr ) high-speed mode ?00 600 2200 2200 2200 t stoso 0.5t sclo + standard mode ?000 4000 4400 4250 4200 2t cyc (? sr ) high-speed mode ?00 600 1350 1200 1150 t sdaso 1t scllo * 3 standard mode ?000 250 3100 3325 3400 (master) 3t cyc (? sr ) high-speed mode ?00 100 400 625 700 t sdaso 1t scll * 3 standard mode ?000 250 1300 2200 2500 (slave) 12t cyc * 2 (? sr ) high-speed mode ?00 100 ?400 * 1 ?00 * 1 ?00 * 1 t sdaho 3t cyc standard mode 0 0 600 375 300 high-speed mode 0 0 600 375 300 notes: the maximum operating frequency for the h8s/2169 and h8s/2149 is 10 mhz. 1. does not meet the i 2 c bus interface specification. remedial action such as the following is necessary: (a) secure a start/stop condition issuance interval; (b) adjust the rise and fall times by means of a pull-up resistor and capacitive load; (c) reduce the transfer rate; (d) select slave devices whose input timing permits this output timing. the values in the above table will vary depending on the settings of the iicx bit and bits cks0 to cks2. depending on the frequency it may not be possible to achieve the maximum transfer rate; therefore, whether or not the i 2 c bus interface specifications are met must be determined in accordance with the actual setting conditions. 2. value when the iicx bit is set to 1. when the iicx bit is cleared to 0, the value is (t scll 6t cyc ). 3. calculated using the i 2 c bus specification values (standard mode: 4700 ns min.; high- speed mode: 1300 ns min.).
528 ? note on icdr read at end of master reception to halt reception at the end of a receive operation in master receive mode, set the trs bit to 1 and write 0 to bbsy and scp in iccr. this changes sda from low to high when scl is high, and generates the stop condition. after this, receive data can be read by means of an icdr read, but if data remains in the buffer the icdrs receive data will not be transferred to icdr, and so it will not be possible to read the second byte of data. if it is necessary to read the second byte of data, issue the stop condition in master receive mode (i.e. with the trs bit cleared to 0). when reading the receive data, first confirm that the bbsy bit in the iccr register is cleared to 0, the stop condition has been generated, and the bus has been released, then read the icdr register with trs cleared to 0. note that if the receive data (icdr data) is read in the interval between execution of the instruction for issuance of the stop condition (writing of 0 to bbsy and scp in iccr) and the actual generation of the stop condition, the clock may not be output correctly in subsequent master transmission. clearing of the mst bit after completion of master transmission/reception, or other modifications of iic control bits to change the transmit/receive operating mode or settings, must be carried out during interval (a) in figure 16.17 (after confirming that the bbsy bit has been cleared to 0 in the iccr register). sda scl internal clock bbsy bit master receive mode icdr reading prohibited bit 0 a 8 9 stop condition (a) start condition execution of stop condition issuance instruction (0 written to bbsy and scp) confirmation of stop condition generation (0 read from bbsy) start condition issuance figure 16.18 points for attention concerning reading of master receive data
529 ? notes on start condition issuance for retransmission figure 16.18 shows the timing of start condition issuance for retransmission, and the timing for subsequently writing data to icdr, together with the corresponding flowchart. after start condition issuance is done and determined the start condition, write the transmit data to icdr, as shown below. read scl pin write transmit data to icdr clear iric in icsr write bbsy = 1, scp = 0 (icsr) iric = 1 ? no scl = low ? no yes start condition issuance ? no [1] [2] [3] [4] [5] [1] [2] [3] [4] [5] wait for end of 1-byte transfer determine whether scl is low issue restart condition instruction for transmission detremine whether start condition is generated or not set transmit data (slave address + r/ w ) note: program so that processing from [3] to [5] is executed continuously. other processing yes yes iric = 1 ? no yes scl bit7 data output ack 9 iric [1] iric determination [2] determination of scl = low [5] icdr write (next transmit data) sda [3] start condition instruction issuance start condition (retransmission) [4] iric determination figure 16.19 flowchart and timing of start condition instruction issuance for retransmission
530 ? notes on i 2 c bus interface stop condition instruction issuance if the rise time of the 9th scl clock exceeds the specification because the bus load capacitance is large, or if there is a slave device of the type that drives scl low to effect a wait, after rising of the 9th scl clock, issue the stop condition after reading scl and determining it to below, as shown below. stop condition scl iric [1] determination of scl = low 9th clock vih high period secured [2] stop condition instruction isuuance sda as waveform rise is late, scl is detected as low generation figure 16.20 timing of stop condition issuance
531 section 17 keyboard buffer controller 17.1 overview the h8s/2169 or h8s/2149 has three on-chip keyboard buffer controller channels, designated 0, 1, and 2. the keyboard buffer controller is provided with functions conforming to the ps/2 interface specifications. data transfer using the keyboard buffer controller employs a data line (kd) and a clock line, providing economical use of connectors, board surface area, etc. figure 17.1 shows how the keyboard buffer controller is connected. 17.1.1 features ? conforms to ps/2 interface specifications ? direct bus drive (via the kclk and kd pins) ? interrupt sources: on completion of data reception and on detection of clock edge ? error detection: parity error and stop bit monitoring vcc kclk in kclk out kd in kd out keyboard buffer controller (h8s/2169 or h8s/2149 chip) system side kclk in kclk out kd in kd out i/f keyboard side vcc clock data figure 17.1 keyboard buffer controller connection
532 17.1.2 block diagram figure 17.2 shows a block diagram of the keyboard buffer controller. kd (ps2ad, ps2bd, ps2cd) kdi kclki kdo kclko parity register counter value kb interrupt kclk (ps2ac, ps2bc, ps2cc) legend: kd: kbc data i/o pin kclk: kbc clock i/o pin kbbr: keyboard data buffer register kbcrh: keyboard control register h kbcrl: keyboard control register l control logic kbbr kbcrh kbcrl bus interface internal data bus module data bus figure 17.2 block diagram of keyboard buffer controller
533 17.1.3 input/output pins table 17.1 lists the input/output pins used by the keyboard buffer controller. table 17.1 keyboard buffer controller input/output pins channel name abbreviation * i/o function 0 kbc clock i/o pin (kclk0) ps2ac i/o kbc clock input/output kbc data i/o pin (kd0) ps2ad i/o kbc data input/output 1 kbc clock i/o pin (kclk1) ps2bc i/o kbc clock input/output kbc data i/o pin (kd1) ps2bd i/o kbc data input/output 2 kbc clock i/o pin (kclk2) ps2cc i/o kbc clock input/output kbc data i/o pin (kd2) ps2cd i/o kbc data input/output note: * these are the external i/o pin names. in the text, clock i/o pins are referred to as kclk and data i/o pins as kd, omitting the channel designations. 17.1.4 register configuration table 17.2 lists the registers of the keyboard buffer controller. table 17.2 keyboard buffer controller registers channel name abbreviation r/w initial value address * 1 0 keyboard control register h kbcrh0 r/(w) * 2 h'70 h'fed8 keyboard control register l kbcrl0 r/w h'70 h'fed9 keyboard data buffer register kbbr0 r h'00 h'feda 1 keyboard control register h kbcrh1 r/(w) * 2 h'70 h'fedc keyboard control register l kbcrl1 r/w h'70 h'fedd keyboard data buffer register kbbr1 r h'00 h'fede 2 keyboard control register h kbcrh2 r/(w) * 2 h'70 h'fee0 keyboard control register l kbcrl2 r/w h'70 h'fee1 keyboard data buffer register kbbr2 r h'00 h'fee2 common module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bits 2 and 1, to clear the flags.
534 17.2 register descriptions 17.2.1 keyboard control register h (kbcrh) bit 76543210 kbioe kclki kdi kbfsel kbie kbf per kbs initial value 0 1 1 1 0 0 0 0 read/write r/w r r r/w r/w r/(w) * r/(w) * r note: * only 0 can be written, to clear the flags. kbcrh is an 8-bit readable/writable register that indicates the operating status of the keyboard buffer controller. kbcrh is initialized to h'70 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 6, 5, and 2 to 0 are also initialized when kbioe is cleared to 0. bit 7?eyboard in/out enable (kbioe): selects whether or not the keyboard buffer controller is used. when kbioe is set to 1, the keyboard buffer controller is enabled for transmission and reception and the port pins function as kclk and kd i/o pins. when kbioe is cleared to 0, the keyboard buffer controller stops functioning and the port pins go to the high- impedance state. bit 7 kbioe description 0 the keyboard buffer controller is non-operational (kclk and kd signal pins have port functions) (initial value) 1 the keyboard buffer controller is enabled for transmission and reception (kclk and kd signal pins are in the bus drive state) bit 6?eyboard clock in (kclki): monitors the kclk i/o pin. this bit cannot be modified. bit 6 kclki description 0 kclk i/o pin is low 1 kclk i/o pin is high (initial value)
535 bit 5?eyboard data in (kdi): monitors the kdi i/o pin. this bit cannot be modified. bit 5 kdi description 0 kd i/o pin is low 1 kd i/o pin is high (initial value) bit 4?eyboard buffer register full select (kbfsel): selects whether the kbf bit is used as the keyboard buffer register full flag or as the kclk fall interrupt flag, when kbfsel is cleared to 0, the kbe bit in the kbcrl register should be cleared to 0 to disable reception. bit 4 kbfsel description 0 kbf bit is used as kclk fall interrupt flag 1 kbf bit is used as keyboard buffer register full flag (initial value) bit 3?eyboard interrupt enable (kbie): enables or disables interrupts from the keyboard buffer controller to the cpu. bit 3 kbie description 0 interrupt requests are disabled (initial value) 1 interrupt requests are enabled bit 2?eyboard buffer register full (kbf): indicates that data reception has been completed and the received data is in the keyboard data buffer register (kbbr). bit 2 kbf description 0 [clearing condition] (initial value) read kbf when kbf =1, then write 0 in kbf 1 [setting condition] ? when data has been received normally and has been transferred to kbbr (keyboard buffer register full flag) ? when a kclk falling edge is detected (while kbfsel = 0) (kclk interrupt flag)
536 bit 1?arity error (per): indicates that an odd parity error has occurred. bit 1 per description 0 [clearing condition] (initial value) read per when per =1, then write 0 in per 1 [setting condition] when an odd parity error occurs bit 0?eyboard stop (kbs): indicates the receive data stop bit. valid only when kbf = 1. bit 0 kbs description 0 0 stop bit received (initial value) 1 1 stop bit received 17.2.2 keyboard control register l (kbcrl) bit 76543210 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 initial value 0 1 1 1 0 0 0 0 read/write r/w r/w r/w r r r r kbcrl is an 8-bit readable/writable register that enables the receive counter count and controls the keyboard buffer controller pin output. kbcrl is initialized to h'70 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bit 7?eyboard enable (kbe): enables or disables loading of receive data into the keyboard data buffer register (kbbr). bit 7 kbe description 0 loading of receive data into kbbr is disabled (initial value) 1 loading of receive data into kbbr is enabled
537 bit 6?eyboard clock out (kclko): controls kbc clock i/o pin output. bit 6 kclko description 0 keyboard buffer controller clock i/o pin is low 1 keyboard buffer controller clock i/o pin is high (initial value) bit 5?eyboard data out (kdo): controls kbc data i/o pin output. bit 5 kdo description 0 keyboard buffer controller data i/o pin is low 1 keyboard buffer controller data i/o pin is high (initial value) bit 4?eserved: this bit cannot be modified and is always read as 1. bits 3 to 0?eceive counter (rxcr3 to rxcr0): these bits indicate the received data bit. their value is incremented on the fall of kclk. these bits cannot be modified. the receive counter is initialized to 0000 by a reset and when 0 is written in kbe. its value returns to 0000 after a stop bit is received. bit 3 bit 2 bit 1 bit 0 rxcr3 rxcr2 rxcr1 rxcr0 receive data contents 0000 (initial value) 1 start bit 1 0 kb0 1 kb1 100kb2 1 kb3 1 0 kb4 1 kb5 1000kb6 1 kb7 1 0 parity bit 1 1
538 17.2.3 keyboard data buffer register (kbbr) bit 76543210 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 initial value 0 0 0 0 0 0 0 0 read/write r r r r r r r r kbbr is a read-only register that stores receive data. its value is valid only when kbf = 1. kbbr is initialized to h'00 by a reset, in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode, and when kbioe is cleared to 0. 17.2.4 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable register, performs module stop mode control. when the mstp2 bit is set to 1, the keyboard buffer controller halts and enters module stop mode. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrl bit 2?odule stop (mstp2): specifies keyboard buffer controller module stop mode. mstpcrl bit 2 mstp2 description 0 keyboard buffer controller module stop mode is cleared 1 keyboard buffer controller module stop mode is set (initial value)
539 17.3 operation 17.3.1 receive operation in a receive operation, both kclk (clock) and kd (data) are outputs on the keyboard side and inputs on the h8s/2169 or h8s/2149 chip (system) side. kd receives a start bit, 8 data bits (lsb- first), an odd parity bit, and a stop bit, in that order. the kd value is valid when kclk is low. a sample receive processing flowchart is shown in figure 17.3, and the receive timing in figure 17.4.
540 start set kbioe bit read kbcrh kclki and kdi bits both 1? set kbe bit receive enabled state kbf = 1? per = 0? kbs = 1? read kbbr receive data processing clear kbf flag (receive enabled state) keyboard side in data transmission state. execute receive abort processing. error handling [1] set the kbioe bit to 1 in kbcrl. [2] read kbcrh, and if the kclki and kdi bits are both 1, set the kbe bit (receive enabled state). [3] detect the start bit output on the keyboard side and receive data in synchronization with the fall of kclk. [4] when a stop bit is received, the keyboard buffer controller drives kclk low to disable keyboard transmission (automatic i/o inhibit). if the kbie bit is set to 1 in kbcrh, an interrupt request is sent to the cpu at the same time. [5] perform receive data processing. [6] clear the kbf flag to 0 in kbcrl. at the same time, the system automatically drives kclk high, setting the receive enabled state. the receive operation can be continued by repeating steps [3] to [6]. [1] [2] [3] [4] [5] [6] yes no yes yes yes no no no figure 17.3 sample receive processing flowchart
541 123 kclk (pin state) kd (pin state) kclk (input) kclk (output) kb7 to kb0 per kbs kbf start bit parity bit stop bit receive processing/ error handling automatic i/o inhibit previous data receive data flag cleared 9 10 11 7 01 kb0 kb1 [1] [2] [3] [4] [5] [6] figure 17.4 receive timing 17.3.2 transmit operation in a transmit operation, kclk (clock) is an output on the keyboard side, and kd (data) is an output on the chip (system) side. kd outputs a start bit, 8 data bits (lsb-first), an odd parity bit, and a stop bit, in that order. the kd value is valid when kclk is high. a sample transmit processing flowchart is shown in figure 17.5, and the transmit timing in figure 17.6.
542 start set kbioe bit kclki = 0? read kbcrh kclki and kdi bits both 1? set i/o inhibit (kclko = 0) kbe = 0 (kbbr reception disabled) kdo remains at 1 wait set start bit (kdo = 0) set i/o inhibit (kclko = 1) kclko remains at 0 kdo remains at 0 i = 0 read kbcrh set transmit data (kdo = d(i)) read kbcrh kclki = 1? i = i + 1 i > 9? read kbcrh kclki = 1? yes no i = 0 to 7: transmit data i = 8: parity bit i = 9: stop bit no yes yes yes yes no no no 1 2 [1] set the kbe bit to 1 in kbcrh, and the kbioe bit to 1 in kbcrl. [2] read kbcrh, and if the kclki and kdi bits are both 1, write 0 in the kclko bit (set i/o inhibit). [3] write 0 in the kbe bit (disable kbbr receive operation). [4] write 0 in the kdo bit (set start bit). [5] write 1 in the kclko bit (clear i/o inhibit). [6] read kbcrh, and when kclki = 0, set the transmit data in the kdo bit (lsb-first). next, set the parity bit and stop bit in the kdo bit. [7] after transmitting the stop bit, read kbcrl and confirm that kdi = 0 (receive completed notification from the keyboard). [8] read kbcrh. confirm that the kclki and kdi bits are both 1. the transmit operation can be continued by repeating steps [2] to [8]. [1] [2] [3] [4] [5] [6] figure 17.5 sample transmit processing flowchart
543 read kbcrh transmit end state (kclk = high, kd = high) yes note: * to switch to reception after transmission, set kbe to 1 ( kbbr receive enable ) while kclki is low. 1 kclki = 0? no kdi = 0? read kbcrh kclk = 1? yes yes no no error handling to receive operation or transmit operation keyboard side in data transmission state. execute receive abort processing. 2 * [7] [8] figure 17.5 sample transmit processing flowchart (cont) 1 01 01 7 7 2891011 kclk (pin state) kd (pin state) kclk (output) kd (output) kclk (input) kd (input) start bit start bit parity bit stop bit parity bit stop bit i/o inhibit receive completed notification [1] [2] [3] [4] [5] [6] [7] [8] figure 17.6 transmit timing
544 17.3.3 receive abort the h8s/2169 or h8s/2149 device (system side) can forcibly abort transmission from the device connected to it (keyboard side) in the event of a protocol error, etc. in this case, the system holds the clock low. during reception, the keyboard also outputs a clock for synchronization, and the clock is monitored when the keyboard output clock is high. if the clock is low at this time, the keyboard judges that there is an abort request from the system, and data transmission from the keyboard is aborted. thus the system can abort reception by holding the clock low for a certain period. a sample receive abort processing flowchart is shown in figure 17.7, and the receive abort timing in figure 17.8.
545 read kbcrl kbf = 0? rxcr3 to rxcr0 3 b'1001? disable receive abort requests yes start receive state read kbcrh processing 1 kclko = 0 (receive abort request) retransmit command transmission (data)? kbe = 0 (disable kbbr reception and clear receive counter) set start bit (kdo = 0) clear i/o inhibit (kclko = 1) transmit data to transmit operation kbe = 0 (disable kbbr reception and clear receive counter) kbe = 1 (enable kb operation) clear i/o inhibit (kclko = 1) to receive operation [1] read kbcrl, and if kbf = 1, perform processing 1. [2] read kbcrh, and if the value of bits rxcr3 to rxcr0 is less than b'1001, write 0 in kclko to abort reception. if the value of bits rxcr3 to rxcr0 is b'1001 or greater, wait until stop bit reception is completed, then perform receive data processing, and proceed to the next operation. [3] if the value of bits rxcr3 to rxcr0 is b'1001 or greater, the parity bit is being received. with the ps2 interface, a receive abort request following parity bit reception is disabled. wait until stop bit reception is completed, perform receive data processing and clear the kbf flag, then proceed to the next operation. yes no no no yes [1] [2] [3] figure 17.7 sample receive abort processing flowchart
546 receive data processing clear kbf flag (kclk = h) processing 1 receive operation ends normally [1] on the system side, drive the kclk pin low, setting the i/o inhibit state. [1] transmit enabled state. if there is transmit data, the data is transmitted. figure 17.7 sample receive abort processing flowchart (cont) keyboard side monitors clock during receive operation (transmit operation as seen from keyboard), and aborts receive operation during this period. kclk (pin state) kd (pin state) kclk (input) kclk (output) kd (input) kd (output) reception in progress receive abort request transmit operation start bit figure 17.8 receive abort and transmit start (transmission/reception switchover) timing
547 17.3.4 kclki and kdi read timing figure 17.9 shows the kclki and kdi read timing. t1 t2 * internal read signal kclk, kd (pin state) kclki, kdi (register) internal data bus (read data) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. figure 17.9 kclki and kdi read timing 17.3.5 kclko and kdo write timing figure 17.10 shows the klcko and kdo write timing and the kclk and kd pin states. internal write signal * kclko, kdo (register) kclk, kd (pin state) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. t1 t2 figure 17.10 kclko and kdo write timing
548 17.3.6 kbf setting timing and kclk control figure 17.11 shows the kbf setting timing and the kclk pin states. kclk (pin) * internal kclk falling edge signal rxcr3 to rxcr0 kclk (output) kbf 11th fall automatic i/o inhibit h'000 h'010 note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. figure 17.11 kbf setting and kclk automatic i/o inhibit generation timing
549 17.3.7 receive timing figure 17.12 shows the receive timing. n + 1 n + 2 n kclk (pin) note: * the ?clock shown here is scaled by 1/n in medium-speed mode when the operating mode is active mode. kd (pin) internal kclk (kclki) falling edge signal rxcr3 to rxcr0 internal kd (kdi) kbbr7 to kbbr0 * figure 17.12 receive counter and kbbr data load timing
550 17.3.8 kclk fall interrupt operation in this device, clearing the kbfsel bit to 0 in kbcrh enables the kbf bit in kbcrl to be used as a flag for the interrupt generated by the fall of kclk input. figure 17.13 shows the setting method and an example of operation. start set kbioe kbf = 1 (interrupt generated) kbe = 0 (kbbr reception disabled) interrupt handling clear kbf kclk pin fall detected? kbfsel = 0 kbie = 1 (kclk falling edge interrupts enabled) yes no kclk (pin state) kbf bit interrupt generated interrupt generated cleared by software note: the kbf setting timing is the same as the timing of kbf setting and kclk automatic i/o inhibit bit generation in figure 17.11. when the kbf bit is used as the kclk input fall interrupt flag, the automatic i/o inhibit function does not operate. figure 17.13 example of kclk input fall interrupt operation
551 17.3.9 usage note when kbioe is 0, the internal kclk and internal kd settings are fixed at 1. therefore, if the kclk pin is low when the kbioe bit is set to 1, the edge detection circuit operates and the kclk falling edge is detected. if the kbfsel bit and kbe bit are both 0 at this time, the kbf bit is set. figure 17.14 shows the timing of kbioe setting and kclk falling edge detection. t1 t2 kclk (pin) internal kclk (kclki) falling edge signal kbioe kbfsel kbe kbf figure 17.14 kbioe setting and kclk falling edge detection timing
552
553 section 18a host interface x-bus interface (xbs) 18a.1 overview the h8s/2169 or h8s/2149 has an on-chip host interface (hif) that enables connection to the isa bus (x-bus) widely used as the internal bus in personal computers. in addition, the h8s/2169 or h8s/2149 has an on-chip lpc interface, a new host interface replacing the isa bus. in the following text, these two host interfaces (hifs) are referred to as xbs and lpc, respectively. the hif:xbs provides a four-channel parallel interface between the chip? internal cpu and a host processor. the hif:xbs is available only when bit hi12e is set to 1 in syscr2 in single-chip mode. do not set bit hi12e to 1 when using the hif:lpc function. 18a.1.1 features the features of the hif:xbs are summarized below. the hif:xbs consists of 8-byte data registers, 4-byte status registers, a 2-byte control register, fast a20 gate logic, and a host interrupt request circuit. communication is carried out via seven control signals from the host processor ( cs1 , cs2 or ecs2 , cs3 , cs4 , ha0, ior , and iow ), six output signals to the host processor (ga20, hirq1, hirq11, hirq12, hirq3, and hirq4), and an 8-bit bidirectional command/data bus (hdb7 to hdb0). the cs1 , cs2 (or ecs2 ), cs3 and cs4 signals select one of the four interface channels.
554 18a.1.2 block diagram figure 18a.1 shows a block diagram of the hif:xbs. internal interrupt signals ibf2 ibf1 control logic hdb7 to hdb0 idr3 odr3 str3 idr4 odr4 str4 hicr2 module data bus host data bus host interrupt request fast a20 gate control port 4, port 8, port b internal data bus bus interface cs1 cs2 / ecs2 cs3 cs4 ior iow ha0 hirq1 hirq11 hirq12 hirq3 hirq4 ga20 hifsd idr1 odr1 str1 idr2 odr2 str2 hicr ibf4 ibf3 legend: idr1: idr2: odr1: odr2: str1: str2: hicr: input data register 1 input data register 2 output data register 1 output data register 2 status register 1 status register 2 host interface control register 1 idr3: idr4: odr3: odr4: str3: str4: hicr2: input data register 3 input data register 4 output data register 3 output data register 4 status register 3 status register 4 host interface control register 2 figure 18a.1 block diagram of hif:xbs
555 18a.1.3 input and output pins table 18a.1 lists the input and output pins of the hif:xbs module. table 18a.1 host interface input/output pins name abbreviation port i/o function i/o read ior p93 input host interface read signal i/o write iow p94 input host interface write signal chip select 1 cs1 p95 input host interface chip select signal for idr1, odr1, str1 chip select 2 * cs2 p81 input host interface chip select signal for idr2, ecs2 p90 odr2, str2 chip select 3 cs3 pb2 input host interface chip select signal for idr3, odr3, str3 chip select 4 cs4 pb3 input host interface chip select signal for idr4, odr4, str4 command/data ha0 p80 input host interface address select signal. in host read access, this signal selects the status registers (str1 to str4) or data registers (odr1 to odr4). in host write access to the data registers (idr1 to idr3, and idtr4), this signal indicates whether the host is writing a command or data. data bus hdb7 to hdb0 p37 to p30 i/o host interface data bus host interrupt 1 hirq1 p44 output interrupt output 1 to host host interrupt 11 hirq11 p43 output interrupt output 11 to host host interrupt 12 hirq12 p45 output interrupt output 12 to host host interrupt 3 hirq3 pb0 output interrupt output 3 to host host interrupt 4 hirq4 pb1 output interrupt output 4 to host gate a20 ga20 p81 output a20 gate control signal output hif shutdown hifsd p82 input host interface shutdown control signal note: * selection of cs2 or ecs2 is by means of the cs2e bit in stcr and the fga20e bit in hicr. hif:xbs channel 2 and the cs2 pin can be used when cs2e = 1. when cs2e = 1, cs2 is used when fga20e =0, and ecs2 is used when fga20e = 1. in this manual, both are referred to as cs2 .
556 18a.1.4 register configuration table 18a.2 lists the hif:xbs registers. hif:xbs registers hicr, idr1, idr2, odr1, odr2, str1, and str2 can only be accessed when the hie bit is set to 1 in syscr. table 18a.2 register configuration abbrevia- r/w initial slave host address * 4 name tion slave host value address * 3 cs1 cs2 cs3 cs4 ha0 system control register syscr r/w * 1 ? h'09 h'ffc4 ? ? ?? ? system control register 2 syscr2 r/w ? h'00 h'ff83 ? ? ?? ? host interface control register 1 hicr r/w ? h'f8 h'fff0 ? ? ?? ? host interface control register 2 hicr2 r/w ? h'f8 h'fe80 ? ? ?? ? input data register 1 idr1 r w ? h'fff4 0 1 11 0/1 * 5 output data register 1 odr1 r/w r ? h'fff5 01110 status register 1 str1 r/(w) * 2 r h'00 h'fff6 01111 input data register 2 idr2 r w ? h'fffc 10110/1 * 5 output data register 2 odr2 r/w r ? h'fffd 10110 status register 2 str2 r/(w )* 2 r h'00 h'fffe 10111 input data register 3 idr3 r w ? h'fe84 11010/1 * 5 output data register 3 odr3 r/w r ? h'fe85 11010 status register 3 str3 r/(w) * 2 r h'00 h'fe86 11011 input data register 4 idr4 r w ? h'fe8c 11100/1 * 5 output data register 4 odr4 r/w r ? h'fe8d 11100 status register 4 str4 r/(w) * 2 r h'00 h'fe8e 11101 module stop control mstpcrh r/w ? h'3f h'ff86 ????? register mstpcrl r/w ? h'ff h'ff87 ????? notes: 1. bits 5 and 3 are read-only bits. 2. the user-defined bits (bits 7 to 4 and 2) are read/write accessible from the slave processor. 3. address when accessed from the slave processor. the lower 16 bits of the address are shown. 4. pin inputs used in access from the host processor. 5. the ha0 input discriminates between writing of commands and data.
557 18a.2 register descriptions 18a.2.1 system control register (syscr) bit initial value read/write 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w syscr is an 8-bit readable/writable register which controls the chip operations. of the host interface registers, hicr, idr1, odr1, str1, idr2, odr2, and str2 can only be accessed when the hie bit is set to 1. hicr2, idr3, odr3, str3, idr4, odr4, and str4 can be accessed regardless of the setting of the hie bit. the host interface cs2 and ecs2 pins are controlled by the cs2e bit in syscr and the fga20e bit in hicr. see section 3.2.2, system control register (syscr), and section 5.2.1, system control register (syscr), for information on other syscr bits. syscr is initialized to h'09 by a reset and in hardware standby mode. bit 7?s2 enable bit (cs2e): used together with the fga20e bit in hicr to select the pin that performs the cs2 pin function when the hi12e bit is set to 1. syscr bit 7 hicr bit 0 cs2e fga20e description 00 cs2 pin function halted ( cs2 fixed high internally) (initial value) 1 10 cs2 pin function selected for p81/ cs2 pin 1 cs2 pin function selected for p90/ ecs2 pin bit 1?ost interface enable bit (hie): enables or disables cpu access to the host interface registers, keyboard matrix interrupt mask register (kmimr), keyboard matrix interrupt mask register a (kmimra), and port 6 mos pull-up control register (kmpcr). when enabled, the host interface registers (hicr, idr1, odr1, str1, idr2, odr2, and str2) can be accessed. bit 1 hie description 0 hif:xbs register (hicr, idr1, odr1, str1, idr2, odr2, str2), cpu access is disabled (initial value) 1 hif:xbs register (hicr, idr1, odr1, str1, idr2, odr2, str2), cpu access is enabled
558 18a.2.2 system control register 2 (syscr2) bit 76543210 kwul1 kwul0 p6pue sde cs4e cs3e hi12e initial value 00000000 read/write r/w r/w r/w r/w r/w r/w r/w syscr2 is an 8-bit readable/writable register which controls the chip operations. host interface functions are enabled or disabled by the hi12e bit in syscr2. the number of channels that can be used can be extended to a maximum of four by means of the cs3e bit and cs4e bit. syscr2 is initialized to h'00 by a reset and in hardware standby mode. bits 7 and 6?ey wakeup level 1 and 0 (kwul1, kwul0): the port 6 input level can be set and changed by software. for details see section 8, i/o ports. bit 5?ort 6 mos input pull-up extra (p6pue): controls and selects the current specification for the port 6 mos input pull-up function connected by means of kmpcr settings. for details see section 8, i/o ports. bit 4?eserved: do not write 1 to this bit. bit 3?hutdown enable (sde): enables or disables the host interface pin shutdown function. when this function is enabled, host interface pin functions can be halted, and the pins placed in the high-impedance state, according to the state of the hifsd pin. bit 3 sde description 0 host interface pin shutdown function disabled (initial value) 1 host interface pin shutdown function enabled bit 2?s4 enable (cs4e): enables or disables host interface channel 4 functions in slave mode. when these functions are enabled, channel 4 pins are enabled and processing can be performed for data transfer between the slave and the host processors. bit 2 cs4e description 0 host interface pin channel 4 functions disabled (initial value) 1 host interface pin channel 4 functions enabled
559 bit 1?s3 enable (cs3e): enables or disables host interface channel 3 functions in slave mode. when these functions are enabled, channel 3 pins are enabled and processing can be performed for data transfer between the slave and the host processors. bit 1 cs3e description 0 host interface pin channel 3 functions disabled (initial value) 1 host interface pin channel 3 functions enabled bit 0?ost interface enable bit (hi12e): enables or disables host interface functions in single-chip mode. when the host interface functions are enabled, processing is performed for data transfer between the slave and the host processors using the pins determined by bits cs2e to cs4e, fga20e, and sde. bit 0 hi12e description 0 host interface functions are disabled (initial value) 1 host interface functions are enabled 18a.2.3 host interface control register (hicr) ? hicr bit initial value slave read/write host read/write 7 1 6 1 5 1 4 1 3 1 0 fga20e 0 r/w 2 ibfie2 0 r/w 1 ibfie1 0 r/w ? hicr2 bit initial value slave read/write host read/write 7 1 6 1 5 1 4 1 3 1 0 0 2 ibfie4 0 r/w 1 ibfie3 0 r/w hicr is an 8-bit readable/writable register which controls host interface channel 1 and 2 interrupts and the fast a20 gate function. hicr2 is an 8-bit readable/writable register which controls host
560 interface channel 3 and 4 interrupts. hicr and hicr2 are initialized to h'f8 by a reset and in hardware standby mode. bits 7 to 3?eserved: these bits cannot be modified and are always read as 1. hicr bits 2 and 1?nput data register full interrupt enable 2 and 1 (ibfie2, ibfie1) hicr2 bits 2 and 1?nput data register full interrupt enable 4 and 3 (ibfie4, ibfie3) these bits enable or disable the ibf1, ibf2, ibf3, and ibf4 interrupts to the internal cpu. hicr2 bit 2 hicr2 bit 1 hicr bit 2 hicr bit 1 ibfie4 ibfie3 ibfie2 ibfie1 description ? input data register (idr1) reception completed interrupt request disabled (initial value) ? input data register (idr1) reception completed interrupt request enabled 0 input data register (idr2) reception completed interrupt request disabled (initial value) 1 input data register (idr2) reception completed interrupt request enabled 0 input data register (idr3) reception completed interrupt request disabled (initial value) 1 input data register (idr3) reception completed interrupt request enabled 0 input data register (idr4) reception completed interrupt request disabled (initial value) 1 input data register (idr4) reception completed interrupt request enabled hicr bit 0?ast a20 gate function enable (fga20e): enables or disables the fast a20 gate function. when the fast a20 gate is disabled, the normal a20 gate can be implemented byte firmware operation of the p81 output. when the host interface (hif:xbs) fast a20 gate function is enabled, the ddr bit for p81 must be set to 1. therefore, the state of the p81/ga20 pin cannot be monitored by reading the dr bit for p81. a fast a20 gate function is also provided in the hif:lpc. the state of the p81/ga20 pin can be monitored by reading the hif:lpc? ga20 bit.
561 hicr bit 0 p8ddr bit 1 fga20e p81ddr description 0 0 hif:xbs fast a20 gate function disabled (initial value) 1 hif:xbs fast a20 gate function disabled 1 0 setting prohibited 1 hif:xbs fast a20 gate function enabled hicr2 bit 0?eserved: do not set to 1. 18a.2.4 input data register (idr) bit initial value slave read/write host read/write 7 idr7 r w 6 idr6 r w 5 idr5 r w 4 idr4 r w 3 idr3 r w 0 idr0 r w 2 idr2 r w 1 idr1 r w idrn (n = 1 to 4) is an 8-bit read-only register to the slave processor, and an 8-bit write-only register to the host processor. when csn (n = 1 to 4) is low, information on the host data bus is written into idrn at the rising edge of iow . the ha0 state is also latched into the c/ d bit in strn to indicate whether the written information is a command or data. the initial values of idr after a reset and in standby mode are undetermined. 18a.2.5 output data register (odr) bit initial value slave read/write host read/write 7 odr7 r/w r 6 odr6 r/w r 5 odr5 r/w r 4 odr4 r/w r 3 odr3 r/w r 0 odr0 r/w r 2 odr2 r/w r 1 odr1 r/w r odrn (n = 1 to 4) is an 8-bit readable/writable register to the slave processor, and an 8-bit read- only register to the host processor. the odrn contents are output on the host data bus when ha0 is low, csn (n = 1 to 4) is low, and ior is low. the initial values of odr after a reset and in standby mode are undetermined.
562 18a.2.6 status register (str) bit initial value slave read/write host read/write note: * onl y 0 can be written, to clear the fla g . 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r/(w) * r 2 dbu 0 r/w r 1 ibf 0 r r strn (n = 1 to 4) is an 8-bit register that indicates status information during host interface processing. bits 3, 1, and 0 are read-only bits to both the host and the slave processors. str is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4 and bit 2?efined by user (dbu): the user can use these bits as necessary. bit 3?ommand/data (c/ d ): receives the ha0 input when the host processor writes to idr, and indicates whether idr contains data or a command. bit 3 c/ d description 0 contents of input data register (idr) are data (initial value) 1 contents of input data register (idr) are a command bit 1?nput buffer full (ibf): set to 1 when the host processor writes to idr. this bit is an internal interrupt source to the slave processor. ibf is cleared to 0 when the slave processor reads idr. the ibf flag setting and clearing conditions are different when the fast a20 gate is used. for details see table 18a.8, fast a20 gate output signals. bit 1 ibf description 0 [clearing condition] when the slave processor reads idr (initial value) 1 [setting condition] when the host processor writes to idr
563 bit 0?utput buffer full (obf): set to 1 when the slave processor writes to odr1. cleared to 0 when the host processor reads odr. bit 0 obf description 0 [clearing condition] when the host processor reads odr or the slave writes 0 in the obf bit (initial value) 1 [setting condition] when the slave processor writes to odr table 18a.3 shows the conditions for setting and clearing the str flags. table 18a.3 set/clear timing for str flags flag setting condition clearing condition c/ d rising edge of host?s write signal ( iow ) when ha0 is high rising edge of host?s write signal ( iow ) when ha0 is low ibf * rising edge of host?s write signal ( iow ) when writing to idr1 falling edge of slave?s internal read signal ( rd ) when reading idr1 obf falling edge of slave?s internal write signal ( wr ) when writing to odr1 rising edge of host?s read signal ( ior ) when reading odr1 note: * the ibf flag setting and clearing conditions are different when the fast a20 gate is used. for details see table 18a.8, fast a20 gate output signals.
564 18a.2.7 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp2 bit is set to 1, the host interface (hif:xbs) halts and enters module stop mode. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrl bit 2?odule stop (mstp2): specifies host interface (hif:xbs) module stop mode. mstpcrl bit 2 mstp2 description 0 host interface (hif: xbs) module stop mode is cleared 1 host interface (hif: xbs) module stop mode is set (initial value) 18a.3 operation 18a.3.1 host interface activation the host interface is activated by setting the hi12e bit (bit 0) in syscr2 to 1 in single-chip mode. when the host interface is activated, all related i/o ports (data port 3, control ports 8 and 9, and host interrupt request port 4) become dedicated host interface ports. setting the cs3e bit and cs4e bit to 1 enables the number of host interface channels to be extended to a four, and makes the channel 3 and 4 related i/o port (part of port b for control and host interrupt requests) a dedicated host interface port. table 18a.4 shows hif host interface channel selection and pin operation.
565 table 18a.4 host interface channel selection and pin operation hi12e cs2e cs3e cs4e operation 0 host interface functions halted 1000 host interface channel 1 only operating operation of channels 2 to 4 halted (no operation as cs2 or ecs2 , cs3 , and cs4 inputs. pins p43, p81, p90, and pb0 to pb3 operate as i/o ports.) 1 host interface channel 1 and 4 functions operating operation of channels 2 and 3 halted (no operation as cs2 or ecs2 and cs3 inputs. pins p43, p81, p90, pb0, and pb2 operate as i/o ports.) 1 0 host interface channel 1 and 3 functions operating operation of channels 2 and 4 halted (no operation as cs2 or ecs2 and cs4 inputs. pins p43, p81, p90, pb1, and pb3 operate as i/o ports.) 1 host interface channel 1, 3, and 4 functions operating operation of channel 2 halted (no operation as cs2 or ecs2 input. pins p43, p81, and p90 operate as i/o ports.) 1 0 0 host interface channel 1 and 2 functions operating operation of channels 3 and 4 halted (no operation as cs3 and cs4 inputs. pins pb0 to pb3 operate as i/o ports.) 1 host interface channel 1, 2, and 4 functions operating operation of channel 3 halted (no operation as cs3 input. pins pb0 and pb2 operate as i/o ports.) 1 0 host interface channel 1 to 3 functions operating operation of channel 4 halted (no operation as cs4 input. pins pb1 and pb3 operate as i/o ports.) 1 host interface channel 1 to 4 functions operating for host read/write timing, see section 25.3.4, timing of on-chip supporting modules.
566 18a.3.2 control states table 18a.5 shows host interface operations from the hif host, and slave operation. table 18a.5 host interface operations from hif host, and slave operation other than csn csn ior iow ha0 operation 1 0000 setting prohibited 1 setting prohibited 1 0 data read from output data register n (odrn) 1 status read from status register n (strn) 1 0 0 data written to input data register n (idrn) 1 command written to input data register n (idrn) 1 0 idle state 1 idle state (n = 1 to 4) 18a.3.3 a20 gate the a20 gate signal can mask address a20 to emulate an addressing mode used by personal computers with an 8086*-family cpu. a regular-speed a20 gate signal can be output under firmware control. fast a20 gate output is enabled by setting the fga20e bit (bit 0) to 1 in hicr (h'fff0). note: * intel microprocessor. regular a20 gate operation: output of the a20 gate signal can be controlled by an h'd1 command followed by data. when the slave processor receives data, it normally uses an interrupt routine activated by the ibf1 interrupt to read idr1. if the data follows an h'd1 command, software copies bit 1 of the data and outputs it at the gate a20 pin. fast a20 gate operation: when the fga20e bit is set to 1, p81/ga20 is used for output of a fast a20 gate signal. bit p81ddr must be set to 1 to assign this pin for output. when the ddr bit for p81 is set to 1, the state of the p81/ga20 pin cannot be monitored by reading the dr bit for p81. the state of the p81/ga20 pin can be monitored by reading the ga20 bit in the hif:lpc? hicr2 register. the initial output from this pin will be a logic 1, which is the initial value. afterward, the host processor can manipulate the output from this pin by sending commands and data. this function is available only when register idr1 is accessed using cs1 . the slave processor decodes the commands input from the host processor. when an h'd1 host command is detected, bit 1 of the data following the host command is output from the ga20 output pin. this operation does not depend on firmware or interrupts, and is faster than the regular processing
567 using interrupts. table 18a.6 lists the conditions that set and clear ga20 (p81). figure 18a.2 shows the ga20 output in flowchart form. table 18a.7 indicates the ga20 output signal values. table 18a.6 ga20 (p81) set/clear timing pin name setting condition clearing condition ga20 (p81) rising edge of the host? write signal ( iow ) when bit 1 of the written data is 1 and the data follows an h'd1 host command rising edge of the host?s write signal ( iow ) when bit 1 of the written data is 0 and the data follows an h'd1 host command also, when bit fga20e in hicr is cleared to 0 start host write h'd1 command received? wait for next byte host write yes data byte? write bit 1 of data byte to dr bit of p81/ga20 yes no no figure 18a.2 ga20 output
568 table 18a.7 fast a20 gate output signal ha0 data/command internal cpu interrupt flag ga20 (p81) remarks 1 0 1 h'd1 command 1 data * 1 h'ff command 0 0 0 q 1 q (1) turn-on sequence 1 0 1 h'd1 command 0 data * 2 h'ff command 0 0 0 q 0 q (0) turn-off sequence 1 0 1/0 h'd1 command 1 data * 1 command other than h'ff and h'd1 0 0 1 q 1 q (1) turn-on sequence (abbreviated form) 1 0 1/0 h'd1 command 0 data * 2 command other than h'ff and h'd1 0 0 1 q 0 q (0) turn-off sequence (abbreviated form) 1 1 h'd1 command command other than h'd1 0 1 q q cancelled sequence 1 1 h'd1 command h'd1 command 0 0 q q retriggered sequence 1 0 1 h'd1 command any data h'd1 command 0 0 0 q 1/0 q(1/0) consecutively executed sequences notes: 1. arbitrary data with bit 1 set to 1. 2. arbitrary data with bit 1 cleared to 0. 18a.3.4 host interface pin shutdown function host interface output can be placed in the high-impedance state according to the state of the hifsd pin. setting the sde bit to 1 in the syscr2 register when the hi12e bit is set to 1 enables the hifsd pin. the hif constantly monitors the hifsd pin, and when this pin goes low, places the host interface output pins (hirq1, hirq11, hirq12, hirq3, hirq4, and ga20) in the high-impedance state. at the same time, the host interface input pins ( cs1 , cs2 or ecs2 , cs3 , cs4 , iow , ior , and ha0) are disabled (fixed at the high input state internally) regardless of the pin states, and the signals of the multiplexed functions of these pins (input block) are similarly fixed internally. as a result, the host interface i/o pins (hdb7 to hdb0) also go to the high- impedance state. this state is maintained while the hifsd pin is low, and when the hifsd pin returns to the high- level state, the pins are restored to their normal operation as host interface pins.
569 table 18a.8 shows the scope of hif pin shutdown. table 18a.8 scope of hif pin shutdown abbreviation port scope of shutdown in slave mode i/o selection conditions ior p93 o input hi12e = 1 iow p94 o input hi12e = 1 cs1 p95 o input hi12e = 1 cs2 p81 d input hi12e = 1 and cs2e = 1 and fga20e = 0 ecs2 p90 d input hi12e = 1 and cs2e = 1 and fga20e = 1 cs3 pb2 d input hi12e = 1 and cs3e = 1 cs4 pb3 d input hi12e = 1 and cs4e = 1 ha0 p80 o input hi12e = 1 hdb7 to hdb0 p37 to p30 o i/o hi12e = 1 hirq11 p43 d output hi12e = 1 and cs2e = 1 and p43ddr = 1 hirq1 p44 d output hi12e = 1 and p44ddr = 1 hirq12 p45 d output hi12e = 1 and p45ddr = 1 hirq3 pb0 d output hi12e = 1 and cs3e = 1 and pb0ddr = 1 hirq4 pb1 d output hi12e = 1 and cs4e = 1 and pb1ddr = 1 ga20 p81 d output hi12e = 1 and fga20e = 1 hifsd p82 ? input hi12e = 1 and sde = 1 notes: o: pins shut down by shutdown function the irq2 / adtrg input signal is also fixed in the case of p90 shutdown, the tmci1/hsynci signal in the case of p43 shutdown, and the tmri/csynci in the case of p45 shutdown. d : pins shut down only when the hif:xbs function is selected by means of a register setting ?: pin not shut down
570 18a.4 interrupts 18a.4.1 ibf1, ibf2, ibf3, ibf4 the host interface can issue four interrupt requests to the slave processor: ibf1, ibf2, ibf3 and ibf4. they are input buffer full interrupts for input data registers idr1, idr2, idr3 and idr4 respectively. each interrupt is enabled when the corresponding enable bit is set. table 18a.9 input buffer full interrupts interrupt description ibf1 requested when ibfie1 is set to 1 and idr1 is full ibf2 requested when ibfie2 is set to 1 and idr2 is full ibf3 requested when ibfie3 is set to 1 and idr3 is full ibf4 requested when ibfie4 is set to 1 and idr4 is full 18a.4.2 hirq11, hirq1, hirq12, hirq3, and hirq4 bits p45dr to p43dr in the port 4 data register (p4dr) and bits pb1odr and pb0odr in the port b data register (pbodr) can be used as host interrupt request latches the corresponding bits in p4dr are cleared to 0 by the host processor? read signal ( ior ). if cs1 and ha0 are low, when ior goes low and the host reads odr1, hirq1 and hirq12 are cleared to 0. if cs2 and ha0 are low, when ior goes low and the host reads odr2, hirq11 is cleared to 0. the corresponding bit in pbodr is cleared to 0 by the host?s read signal ( ior ). if cs3 and ha0 are low, when ior goes low and the host reads odr3, hirq3 is cleared to 0. if cs4 and ha0 are low, when ior goes low and the host reads odr4, hirq4 is cleared to 0. to generate a host interrupt request, normally on-chip firmware writes 1 in the corresponding bit. in processing the interrupt, the host?s interrupt handling routine reads the output data register (odr1, odr2, odr3, or odr4) and this clears the host interrupt latch to 0. table 18a.10 indicates how these bits are set and cleared. figure 18a.3 shows the processing in flowchart form.
571 table 18a.10 hirq setting/clearing conditions host interrupt signal setting condition clearing condition hirq11 (p43) internal cpu reads 0 from bit p43dr, then writes 1 internal cpu writes 0 in bit p43dr, or host reads output data register 2 hirq1 (p44) internal cpu reads 0 from bit p44dr, then writes 1 internal cpu writes 0 in bit p44dr, or host reads output data register 1 hirq12 (p45) internal cpu reads 0 from bit p45dr, then writes 1 internal cpu writes 0 in bit p45dr, or host reads output data register 1 hirq3 (pb0) internal cpu reads 0 from bit pb0odr, then writes 1 internal cpu writes 0 in bit pb0odr, or host reads output data register 3 hirq4 (pb1) internal cpu reads 0 from bit pb1odr, then writes 1 internal cpu writes 0 in bit pb1odr, or host reads output data register 4 slave cpu master cpu write to odr write 1 to p4dr p4dr = 0? yes no no yes all bytes transferred? hirq output high hirq output low interrupt initiation odr read hardware operations software operations figure 18a.3 hirq output flowchart (example of channels 1 and 2) hirq setting/clearing contention: if there is contention between a p4dr or pbodr read/write by the cpu and p4dr (hirq11, hirq1, hirq12) or pbodr (hirq3, hirq4) clearing by the host, clearing by the host is held pending during the p4dr or pbodr read/write by the cpu. p4dr or pbodr clearing is executed after completion of the read/write.
572 18a.5 usage note note the following when using the xbs function. (1) transmitting/receiving sequence of the transfer between the host and slave processors the host interface provides buffering of asynchronous data from the host and slave processors, but an interface protocol must be followed to implement necessary functions and avoid data contention. for example, if the host and slave processors try to access the same input or output data register simultaneously, the data will be corrupted. interrupts can be used to design a simple and effective protocol. (2) data contention on the host interface data bus (hdb) when the hif function is used and channel 3 or channel 4 is not used, the following condition must be satisfied. (1) the unselected channel pins must be fixed at a high level. (2) port b must not be read. (3) through-current at the pins cs1 to cs4 also, if two or more of pins cs1 to cs4 are driven low simultaneously in attempting idr or odr access, signal contention will occur within the chip, and a through-current may result. this usage must therefore be avoided.
573 section 18b host interface lpc interface (lpc) 18b.1 overview the h8s/2169 or h8s/2149 has an on-chip host interface (hif) that can be connected to the isa bus (x-bus) widely used as the internal bus in personal computers. in addition, the h8s/2169 or h8s/2149 has an on-chip lpc interface, a new host interface replacing the isa bus. in the following text, these two host interfaces (hifs) are referred to as xbs and lpc, respectively. the hif:lpc performs serial transfer of cycle type, address, and data, synchronized with the 33 mhz pci clock. it uses four signal lines for address/data, and one for host interrupt requests. various kinds of cycle are available for the lpc interface, but the chip? hif:lpc supports only i/o read cycle and i/o write cycle transfers. the hif:lpc consists of three register sets comprising data and status registers, plus a control register, fast a20 gate logic, and a host interrupt request circuit. it is also provided with power- down functions that can control the pci clock and shut down the host interface. the hif:lpc ia available only in single-chip mode. 18b.1.1 features the features of the hif:lpc are summarized below. ? supports lpc interface i/o read cycles and i/o write cycles ? uses four signal lines (lad3 to lad0) to transfer the cycle type, address, and data. ? uses three control signals: clock (lclk), reset ( lreset ), and frame ( lframe ). has three register sets comprising data and status registers ? the basic register set comprises three bytes: an input register (idr), output register (odr), and status register (str). ? channels 1 and 2 have fixed i/o addresses of h'60/h'64 and h'62/h'66, respectively, enabling the same functions to be implemented as on hif:xbs channels 1 and 2. ? a fast a20 gate function is also provided. ? the i/o address can be set for channel 3. sixteen two-way register bytes can be manipulated in addition to the basic register set. supports serirq ? host interrupt requests are transferred serially on a single signal line (serirq). ? on channel 1, hirq1 and hirq12 can be generated. ? on channels 2 and 3, smi, hirq6, and hirq9 to hirq11 can be generated.
574 ? operation can be switched between quiet mode and continuous mode. ? the clkrun signal can be manipulated to restart the pci clock (lclk). power-down functions, interrupts, etc. ? the lpc module can be shut down by inputting the lpcpd signal. ? three pins, pme , lsmi , and lsci, are provided for general input/output. 18b.1.2 block diagram figure 18b.1 shows a block diagram of the hif:lpc. twr1?5 idr3 idr2 idr1 h'0060/64 h'0062/66 ladr3 sirqcr0 sirqcr1 twr0mw twr1?5 odr3 odr2 odr1 str3 str2 str1 hicr0 hicr1 hicr2 hicr3 twr0sw lscie lscib lsci input pb1 i/o lsmie lsmib lsmi input pb0 i/o pmee pmeb pme input p80 i/o lad0 lad3 serirq clkrun lsci lsmi pme ga20 lpcpd lframe lreset lclk ibf interrupts (ibfi1, ibfi2, ibfi3) err interrupt (erri) module data bus cycle detection serial parallel conversion serial parallel conversion address match sync output parallel serial conversion control logic internal interrupt control figure 18b.1 block diagram of hif:lpc
575 18b.1.3 pin configuration table 18b.1 lists the input and output pins of the hif:lpc module. table 18b.1 pin configuration name abbreviation port i/o function lpc address/ data 3 to 0 lad3 to lad0 p33 to p30 input/ output serial (4-signal-line) transfer cycle type/address/data signals, synchronized with lclk lpc frame lframe p34 input * 1 transfer cycle start and forced termination signal lpc reset lreset p35 input * 1 lpc interface reset signal lpc clock lclk p36 input 33 mhz pci clock signal serialized interrupt request serirq p37 input/ output * 1 serialized host interrupt request signal, synchronized with lclk (smi, irq1, irq6, irq9 to irq12) lsci general output lsci pb1 output * 1, * 2 general output lsmi general output lsmi pb0 output * 1, * 2 general output pme general output pme p80 output * 1, * 2 general output gate a20 ga20 p81 output * 1, * 2 a20 gate control signal output lpc clock run clkrun p82 input/ output * 1, * 2 lclk restart request signal in case of serial host interrupt request lpc power-down lpcpd p83 input * 1 lpc module shutdown signal notes: 1. pin state monitoring input is possible in addition to the lpc interface control input/output function. 2. only 0 can be output. if 1 is output, the pin goes to the high-impedance state, so an external resistor is necessary to pull the signal up to v cc .
576 18b.1.4 register configuration table 18b.2 lists the hif:lpc registers. table 18b.2 register configuration abbrevia- r/w initial slave host name tion slave host value address * 3 address * 4 system control register syscr r/w * 1 h'09 h'ffc4 system control register 2 syscr2 r/w h'00 h'ff83 host interface control register 0 hicr0 r/w h'00 h'fe40 host interface control register 1 hicr1 r/w h'00 h'fe41 host interface control register 2 hicr2 r/w h'00 h'fe42 host interface control register 3 hicr3 r h'fe43 lpc channel 3 address ladr3h r/w h'00 h'fe34 register ladr3l r/w h'00 h'fe35 input data register 1 idr1 r w h'fe38 h'0060 and h'0064 output data register 1 odr1 r/w r h'fe39 h'0060 status register 1 str1 r/(w) * 2 r h'00 h'fe3a h'0064 input data register 2 idr2 r w h'fe3c h'0062 and h'0066 output data register 2 odr2 r/w r h'fe3d h'0062 status register 2 str2 r/(w) * 2 r h'00 h'fe3e h'0066 input data register 3 idr3 r w h'fe30 ladr3 * 5 +0 and +4 output data register 3 odr3 r/w r h'fe31 ladr3 * 5 +0 status register 3 str3 r/(w) * 2 r h'00 h'fe32 ladr3 * 5 +4 two-way register 0mw twr0mw r w h'fe20 ladr3 * 6 +16 /?6 two-way register 0sw twr0sw w r h'fe20 ladr3 * 6 +16 /?6
577 abbrevia- r/w initial slave host name tion slave host value address * 3 address * 4 two-way registers 1 to 15 twr1 to twr15 r/w r/w h'fe21 to h'fe2f ladr3 * 6 +17/?5 to ladr3 * 6 +31/? serirq control register 0 sirqcr0 r/w h'00 h'fe36 serirq control register 1 sirqcr1 r/w h'00 h'fe37 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 notes: 1. bits 5 and 3 are read-only bits. 2. the user-defined bits (channels 1 and 2: bits 7 to 4 and 2; channel 3: bit 2) are read/write accessible from the slave processor. 3. address when accessed from the slave processor. the lower 16 bits of the address are shown. 4. address when accessed from the host processor. 5. +0 and +4 address calculation is performed, with bit 0 of ladr3 regarded as b'0. 6. +31 to ?6 address calculation is performed, with bits 3 to 0 of ladr3 regarded as b'0000. 18b.2 register descriptions 18b.2.1 system control registers (syscr, syscr2) ? syscr bit 76543210 cs2e iose intm1 intm0 xrst nmieg hie rame initial value 0 0 0 0 1 0 0 1 read/write r/w r/w r r/w r r/w r/w r/w ? syscr2 bit 76543210 kwul1 kwul0 p6pue sde cs4e cs3e hi12e initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w
578 syscr and syscr2 are 8-bit readable/writable registers that control the chip operations. the settings of hif:xbs related bits do not affect the operation of the chip?s hif:lpc. however, for reasons relating to the configuration of the program development tool (emulator), when the hif:lpc is used, bit hi12e in syscr2 should not be set to 1. for details of the individual bits, see section 18a.2.1, system control register (syscr), section 18a.2.2, system control register 2 (syscr2), section 3.2.2, system control register (syscr), section 5.2.1, system control register (syscr), and section 8, i/o ports. syscr and syscr2 are initialized to h'09 and h'00, respectively, by a reset and in hardware standby mode. 18b.2.2 host interface control registers 0 and 1 (hicr0, hicr1) ? hicr0 bit 76543210 lpc3e lpc2e lpc1e fga20e sdwne pmee lsmie lscie initial value 00000000 slave read/write r/w r/w r/w r/w r/w r/w r/w r/w host read/write ? hicr1 bit 76543210 lpcbsy clkreq irqbsy lrstb sdwnb pmeb lsmib lscib initial value 00000000 slave read/write r r r r/w r/w r/w r/w r/w host read/write hicr0 and hicr1 contain control bits that enable or disable host interface functions, control bits that determine pin output and the internal state of the host interface, and status flags that monitor the internal state of the host interface. hicr0 and hicr1 are initialized to h'00 by a reset and in hardware standby mode.
579 hicr0 bits 7 to 5?pc enable 3 to 1 (lpc3e, lpc2e, lpc1e): these bits enable or disable the host interface function in single-chip mode. when the host interface is enabled (at least one of the three bits is set to 1), processing for data transfer between the slave processor and the host processor is performed using pins lad3 to lad0, lframe , lreset , lclk, serirq, clkrun , and lpcpd . hicr0 bit 7 lpc3e description 0 lpc channel 3 operation is disabled (initial value) no address (ladr3) matches for idr3, odr3, str3, or twr0 to twr15 1 lpc channel 3 operation is enabled hicr0 bit 6 lpc2e description 0 lpc channel 2 operation is disabled (initial value) no address (h'0062, 66) matches for idr2, odr2, or str2 1 lpc channel 2 operation is enabled hicr0 bit 5 lpc1e description 0 lpc channel 1 operation is disabled (initial value) no address (h'0060, 64) matches for idr1, odr1, or str1 1 lpc channel 1 operation is enabled
580 hicr0 bit 4?ast a20 gate function enable (fga20e): enables or disables the fast a20 gate function. when the fast a20 gate is disabled, the normal a20 gate can be implemented by firmware operation of the p81 output. when the fast a20 gate function is enabled, the ddr bit for p81 must not be set to 1. hicr0 bit 4 fga20e description 0 fast a20 gate function disabled (initial value) ? other function of pin p81 is enabled ? ga20 output internal state is initialized to 1 1 fast a20 gate function enabled ? ga20 pin output is open-drain (external v cc pull-up resistor required) hicr0 bit 2?me output enable (pmee) hicr1 bit 2?me output bit (pmeb) these bits control pme output. pme pin output is open-drain, and an external pull-up resistor is needed to pull the output up to v cc . when the pme output function is used, the ddr bit for p80 must not be set to 1. hicr0 bit 2 hicr1 bit 2 pmee pmeb description 0 0 pme output disabled, other function of pin p80 is enabled (initial value) 1 pme output disabled, other function of pin p80 is enabled 1 0 pme output enabled, pme pin output goes to 0 level 1 pme output enabled, pme pin output is high-impedance
581 hicr0 bit 1?smi output enable (lsmie) hicr1 bit 1?smi output bit (lsmib) these bits control lsmi output. lsmi pin output is open-drain, and an external pull-up resistor is needed to pull the output up to v cc . when the lsmi output function is used, the ddr bit for pb0 must not be set to 1. hicr0 bit 1 hicr1 bit 1 lsmie lsmib description 0 0 lsmi output disabled, other function of pin pb0 is enabled (initial value) 1 lsmi output disabled, other function of pin pb0 is enabled 1 0 lsmi output enabled, lsmi pin output goes to 0 level 1 lsmi output enabled, lsmi pin output is high-impedance hicr0 bit 0?sci output enable (lscie) hicr1 bit 0?sci output bit (lscib) these bits control lsci output. lsci pin output is open-drain, and an external pull-up resistor is needed to pull the output up to v cc . when the lsci output function is used, the ddr bit for pb1 must not be set to 1. hicr0 bit 0 hicr1 bit 0 lscie lscib description 0 0 lsci output disabled, other function of pin pb1 is enabled (initial value) 1 lsci output disabled, other function of pin pb1 is enabled 1 0 lsci output enabled, lsci pin output goes to 0 level 1 lsci output enabled, lsci pin output is high-impedance
582 hicr1 bit 7?pc busy (lpcbsy): indicates that the host interface is processing a transfer cycle. hicr1 bit 7 lpcbsy description 0 host interface is in transfer cycle wait state (initial value) ? bus idle, or transfer cycle not subject to processing is in progress ? cycle type or address indeterminate during transfer cycle [clearing conditions] ? lpc hardware reset or lpc software reset ? lpc hardware shutdown or lpc software shutdown ? forced termination (abort) of transfer cycle subject to processing ? normal termination of transfer cycle subject to processing 1 host interface is performing transfer cycle processing [setting condition] ? match of cycle type and address hicr1 bit 6?clk request (clkreq): indicates that the host interface? serirq output is requesting a restart of lclk. hicr1 bit 6 clkreq description 0 no lclk restart request (initial value) [clearing conditions] ? lpc hardware reset or lpc software reset ? lpc hardware shutdown or lpc software shutdown ? serirq is set to continuous mode ? there are no further interrupts for transfer to the host in quiet mode 1 lclk restart request issued [setting condition] ? in quiet mode, serirq interrupt output becomes necessary while lclk is stopped
583 hicr1 bit 5?erirq busy (irqbsy): indicates that the host interface? serirq signal is engaged in transfer processing. hicr1 bit 5 irqbsy description 0 serirq transfer frame wait state (initial value) [clearing conditions] ? lpc hardware reset or lpc software reset ? lpc hardware shutdown or lpc software shutdown ? end of serirq transfer frame 1 serirq transfer processing in progress [setting condition] ? start of serirq transfer frame hicr1 bit 4?pc software reset bit (lrstb): resets the host interface. for the scope of initialization by an lpc reset, see section 18b.3.4, host interface shutdown function. hicr1 bit 4 lrstb description 0 normal state (initial value) [clearing conditions] ? writing 0 ? lpc hardware reset 1 lpc software reset state [setting condition] ? writing 1 after reading lrstb = 0
584 hicr0 bit 3?pc software shutdown enable (sdwne) hicr1 bit 3?pc software shutdown bit (sdwnb) these bits control host interface shutdown. for details of the lpc shutdown function, and the scope of initialization by an lpc reset and an lpc shutdown, see section 18b.3.4, host interface shutdown function. hicr0 bit 3 sdwne description 0 normal state, lpc software shutdown setting enabled (initial value) [clearing conditions] ? writing 0 ? lpc hardware reset or lpc software reset ? lpc hardware shutdown release (rising edge of lpcpd signal) 1 lpc hardware shutdown state setting enabled hardware shutdown state when lpcpd signal is low [setting condition] writing 1 after reading sdwne = 0 hicr1 bit 3 sdwnb description 0 normal state (initial value) [clearing conditions] writing 0 lpc hardware reset or lpc software reset lpc hardware shutdown (falling edge of lpcpd signal when sdwne = 1) lpc hardware shutdown release (rising edge of lpcpd signal when sdwne = 0) 1 lpc software shutdown state [setting condition] writing 1 after reading sdwnb = 0
585 18b.2.3 host interface control registers 2 and 3 (hicr2, hicr3) ? hicr2 bit 76543210 ga20 lrst sdwn abrt ibfie3 ibfie2 ibfie1 errie initial value 00000000 slave read/write r r/(w) * r/(w) * r/(w) * r/w r/w r/w r/w host read/write note: * only 0 can be written to bits 6 to 4, to clear the flags. ? hicr3 bit 76543210 lframe clkrun serirq lreset lpcpd pme lsmi lsci initial value 00000000 slave read/write rrrrrrrr host read/write hicr2 and hicr3 contain flags and bits that control interrupts from the host interface (lpc) module to the slave processor, and bits that monitor host interface pin states. bits 6 to 0 of hicr2 are initialized to h'00 by a reset and in hardware standby mode. the states of the other bits are determined by the pin states. hicr2 bit 7?a20 pin monitor (ga20) hicr3 bit 7 lframe pin monitor (lframe) hicr3 bit 6 clkrun pin monitor (clkrun) hicr3 bit 5?erirq pin monitor (serirq) hicr3 bit 4 lreset pin monitor (lreset) hicr3 bit 3 lpcpd pin monitor (lpcpd) hicr3 bit 2 pme pin monitor (pme) hicr3 bit 1 lsmi pin monitor (lsmi) hicr3 bit 0?sci pin monitor (lsci) these are pin state monitoring bits. the pin states can be monitored regardless of the host interface operating state or the operating state of the functions that use pin multiplexing.
586 hicr2 bit 6?pc reset interrupt flag (lrst): interrupt flag that generates an erri interrupt when an lpc hardware reset occurs. hicr2 bit 6 lrst description 0 [clearing condition] (initial value) ? writing 0 after reading lrst = 1 1 [setting condition] ? lreset pin falling edge detection hicr2 bit 5?pc shutdown interrupt flag (sdwn): interrupt flag that generates an erri interrupt when an lpc hardware shutdown request is generated. hicr2 bit 5 sdwn description 0 [clearing conditions] (initial value) ? writing 0 after reading sdwn = 1 ? lpc hardware reset ( lreset pin falling edge detection) lpc software reset (lrstb = 1) 1 [setting condition] lpcpd pin falling edge detection
587 hicr2 bit 4?pc abort interrupt flag (abrt): interrupt flag that generates an erri interrupt when a forced termination (abort) of an lpc transfer cycle occurs. hicr2 bit 4 abrt description 0 [clearing conditions] (initial value) ? writing 0 after reading abrt = 1 ? lpc hardware reset ( lreset pin falling edge detection) lpc software reset (lrstb = 1) lpc hardware shutdown (sdwne = 1 and lpcpd falling edge detection) lpc software shutdown (sdwnb = 1) 1 [setting condition] lframe pin falling edge detection during lpc transfer cycle hicr2 bit 3?dr3 and twr receive complete interrupt enable (ibfie3) hicr2 bit 2?dr2 receive complete interrupt enable (ibfie2) hicr2 bit 1?dr1 receive complete interrupt enable (ibfie1) hicr2 bit 0?rror interrupt enable (errie) these bits enable or disable ibfi1, ibfi2, ibfi3, and erri interrupts to the slave processor. hicr2 bit 3 hicr2 bit 2 hicr2 bit 1 hicr2 bit 0 ibfie3 ibfie2 ibfie1 errie description ? error interrupt requests disabled (initial value) ? error interrupt requests enabled 0 input data register idr1 receive completed interrupt request disabled (initial value) 1 input data register idr1 receive completed interrupt request enabled 0 input data register idr2 receive completed interrupt request disabled (initial value) 1 input data register idr2 receive completed interrupt request enabled 0 input data register idr3 and twr receive completed interrupt requests disabled (initial value) 1 input data register idr3 and twr receive completed interrupt requests enabled
588 18b.2.4 lpc channel 3 address register (ladr3) ladr3h ladr3l bit 7654321076543210 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 1 twre initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w idr3, odr3, str3 address bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 1/0 bit 1 0 twr0?wr15 address bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 1/0 1/0 1/0 1/0 ladr3 comprises two 8-bit readable/writable registers that perform lpc channel 3 host address setting and control the operation of the two-way registers. the contents of the address field in ladr3 must not be changed while channel 3 is operating (while lpc3e is set to 1). ladr3 is initialized to h'0000 by a reset and in hardware standby mode. it is not initialized in software standby mode. ladr3h bits 7 to 0: channel 3 address bits 15 to 8 ladr3l bits 7 to 3 and 1: channel 3 address bits 7 to 3 and 1 when lpc3e = 1, an i/o address received in an lpc i/o cycle is compared with the contents of ladr3. when determining an idr3, odr3, or str3 address match, bit 0 of ladr3 is regarded as 0, and the value of bit 2 is ignored. when determining a twr0 to twr15 address match, bit 4 of ladr3 is inverted, and the values of bits 3 to 0 are ignored. register selection according to the bits ignored in address match determination is as shown in the following table.
589 i/o address transfer bit 4 bit 3 bit 2 bit 1 bit 0 cycle host register selection bit 4 bit 3 0 bit 1 0 i/o write idr3 write, c/ d 3 ? 0 bit 4 bit 3 1 bit 1 0 i/o write idr3 write, c/ d 3 ? 1 bit 4 bit 3 0 bit 1 0 i/o read odr3 read bit 4 bit 3 1 bit 1 0 i/o read str3 read bit 4 0000 i/o write twr0mw write bit 4 0001 i/o write twr1 to twr15 write 1111 bit 4 0000 i/o read twr0sw read bit 4 0001 i/o read twr1 to twr15 read 1111 ladr3l bit 2?eserved: this is a readable/writable reserved bit. ladr3l bit 0?wo-way register enable (twre): enables or disables two-way register operation. ladr3l bit 0 twre description 0 twr operation is disabled (initial value) twr-related i/o address match determination is halted 1 twr operation is enabled 18b.2.5 input data registers (idr1, idr2, idr3) bit 76543210 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 initial value slave read/write rrrrrrrr host read/write wwwwwwww
590 the idr registers are 8-bit read-only registers to the slave processor, and 8-bit write-only registers to the host processor. the registers selected from the host according to the i/o address are shown in the following table. for information on idr3 selection, see section 18b.2.4, lpc channel 3 address register (ladr3). data transferred in an lpc i/o write cycle is written to the selected register. the state of bit 2 of the i/o address is latched into the c/ d bit in str, to indicate whether the written information is a command or data. the initial values of the idr registers after a reset and in standby mode are undetermined. i/o address transfer bits 15 to 4 bit 3 bit 2 bit 1 bit 0 cycle host register selection 0000 0000 0110 0000 i/o write idr1 write, c/ d 1 ? 0 0000 0000 0110 0100 i/o write idr1 write, c/ d 1 ? 1 0000 0000 0110 0010 i/o write idr2 write, c/ d 2 ? 0 0000 0000 0110 0110 i/o write idr2 write, c/ d 2 ? 1 18b.2.6 output data registers (odr1, odr2, odr3) bit 76543210 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 initial value slave read/write r/w r/w r/w r/w r/w r/w r/w r/w host read/write rrrrrrrr the odr registers are 8-bit readable/writable registers to the slave processor, and 8-bit read-only registers to the host processor. the registers selected from the host according to the i/o address are shown in the following table. for information on odr3 selection, see section 18b.2.4, lpc channel 3 address register (ladr3). in an lpc i/o read cycle, the data in the selected register is transferred to the host. the initial values of the odr registers after a reset and in standby mode are undetermined. i/o address transfer bits 15 to 4 bit 3 bit 2 bit 1 bit 0 cycle host register selection 0000 0000 0110 0000 i/o read odr1 read 0000 0000 0110 0010 i/o read odr2 read
591 18b.2.7 two-way data registers (twr0 to twr15) ? twr0mw bit 76543210 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 initial value slave read/write rrrrrrrr host read/write wwwwwwww ? twr0sw bit 76543210 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 initial value slave read/write wwwwwwww host read/write rrrrrrrr ? twr1 to twr15 bit 76543210 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 initial value slave read/write r/w r/w r/w r/w r/w r/w r/w r/w host read/write r/w r/w r/w r/w r/w r/w r/w r/w twr0 to twr15 are sixteen 8-bit readable/writable registers to both the slave processor and the host processor. in twr0, however, two registers (twr0mw and twr0sw) are allocated to the same address for both the host address and the slave address. twr0mw is a write-only register to the host processor, and a read-only register to the slave processor, while twr0sw is a write-only register to the slave processor and a read-only register to the host processor. when the host and slave processors begin a write, after the respective twr0 registers have been written to, access right arbitration for simultaneous access is performed by checking the status flags to see if those writes were valid. for the registers selected from the host according to the i/o address, see section 18b.2.4, lpc channel 3 address register (ladr3). data transferred in an lpc i/o write cycle is written to the selected register; in an lpc i/o read cycle, the data in the selected register is transferred to the host. the initial values of twr0 to twr15 after a reset and in standby mode are undetermined.
592 18b.2.8 status registers (str1, str2, str3) ? str1 bit 76543210 dbu17 dbu16 dbu15 dbu14 c/ d 1 dbu12 ibf1 obf1 initial value 00000000 slave read/write r/w r/w r/w r/w r r/w r r/(w) * host read/write rrrrrrrr note: * only 0 can be written, to clear the flag. str2 bit 76543210 dbu27 dbu26 dbu25 dbu24 c/ d 2 dbu22 ibf2 obf2 initial value 00000000 slave read/write r/w r/w r/w r/w r r/w r r/(w) * host read/write rrrrrrrr note: * only 0 can be written, to clear the flag. str3 bit 76543210 ibf3b obf3b mwmf swmf c/ d 3 dbu32 ibf3a obf3 initial value 00000000 slave read/write r r/(w) * r r/(w) * r r/w r r/(w) * host read/write rrrrrrrr note: * only 0 can be written, to clear the flag. the str registers are 8-bit registers that indicate status information during host interface processing. bits 3, 1, and 0 of str1 to str3, and bits 7 to 4 of str3, are read-only bits to both the host processor and the slave processor. however, 0 only can be written from the slave processor to bit 0 of str1 to str3, and bits 6 and 4 of str3, in order to clear the flags to 0. the registers selected from the host processor according to the i/o address are shown in the following table. for information on str3 selection, see section 18b.2.4, lpc channel 3 address register (ladr3). in an lpc i/o read cycle, the data in the selected register is transferred to the host processor. the str registers are initialized to h'00 by a reset and in standby mode.
593 i/o address transfer bits 15 to 4 bit 3 bit 2 bit 1 bit 0 cycle host register selection 0000 0000 0110 0100 i/o read str1 read 0000 0000 0110 0110 i/o read str2 read str1, str2 bits 7 to 4 and 2?efined by user (dbu17 to dbu14, dbu12; dbu27 to dbu24, dbu22) str3 bit 2?defined by user (dbu32) the user can use these bits as necessary. str1, str2, str3 bit 3?ommand/data (c/ d 1, c/ d 2, c/ d 3): when the host processor writes to an idr register, bit 2 of the i/o address is written into this bit to indicate whether idr contains data or a command. bit 3 c/ d description 0 contents of data register (idr) are data (initial value) 1 contents of data register (idr) are a command str1, str2, str3 bit 1?nput buffer full (ibf1, ibf2, ibf3a): set to 1 when the host processor writes to idr. this bit is an internal interrupt source to the slave processor. ibf is cleared to 0 when the slave processor reads idr. the ibf1 flag setting and clearing conditions are diffrent when the fast a20 gate is used. for details see table 18b.4, fast a20 gate output signals. bit 1 ibf description 0 [clearing condition] (initial value) when the slave processor reads idr 1 [setting condition] when the host processor writes to idr using i/o write cycle
594 str1, str2, str3 bit 0?utput buffer full (obf1, obf2, obf3a): set to 1 when the slave processor writes to odr. cleared to 0 when the host processor reads odr. bit 0 obf description 0 [clearing condition] (initial value) when the host processor reads odr using i/o read cycle, or the slave processor writes 0 in the obf bit 1 [setting condition] when the slave processor writes to odr str3 bit 7?wo-way register input buffer full (ibf3b): set to 1 when the host processor writes to twr15. this is an internal interrupt source to the slave processor. ibf3b is cleared to 0 when the slave processor reads twr15. bit 7 ibf3b description 0 [clearing condition] (initial value) when the slave processor reads twr15 1 [setting condition] when the host processor writes to twr15 using i/o write cycle str3 bit 6?wo-way register output buffer full (obf3b): set to 1 when the slave processor writes to twr15. obf3b is cleared to 0 when the host processor reads twr15. bit 6 obf3b description 0 [clearing condition] (initial value) when the host processor reads twr15 using i/o read cycle, or the slave processor writes 0 in the obf3b bit 1 [setting condition] when the slave processor writes to twr15
595 str3 bit 5?aster write mode flag (mwmf): set to 1 when the host processor writes to twr0. mwmf is cleared to 0 when the slave processor reads twr15. bit 5 mwmf description 0 [clearing condition] (initial value) when the slave processor reads twr15 1 [setting condition] when the host processor writes to twr0 using i/o write cycle when swmf = 0 str3 bit 4?lave write mode flag (swmf): set to 1 when the slave processor writes to twr0. in the event of simultaneous writes by the master and the slave, the master write has priority. swmf is cleared to 0 when the host reads twr15. bit 4 swmf description 0 [clearing condition] (initial value) when the host processor reads twr15 using i/o read cycle, or the slave processor writes 0 in the swmf bit 1 [setting condition] when the slave processor writes to twr0 when mwmf = 0 18b.2.9 serirq control registers (sirqcr0, sirqcr1) ? sirqcr0 bit 76543210 q/ c ? iedir smie3b smie3a smie2 irq12e1 irq1e1 initial value 00000000 slave read/write r r/w r/w r/w r/w r/w r/w r/w host read/write ????????
596 sirqcr1 bit 76543210 irq11e3 irq10e3 irq9e3 irq6e3 irq11e2 irq10e2 irq9e2 irq6e2 initial value 00000000 slave read/write r/w r/w r/w r/w r/w r/w r/w r/w host read/write ???????? the sirqcr registers contain status bits that indicate the serirq operating mode and bits that specify serirq interrupt sources. the sirqcr registers are initialized to h'00 by a reset and in hardware standby mode. sirqcr0 bit 7?uiet/continuous mode flag (q/ c ): indicates the mode specified by the host at the end of an serirq transfer cycle (stop frame). bit 7 q/ c description 0 continuous mode (initial value) [clearing conditions] lpc hardware reset, lpc software reset specification by serirq transfer cycle stop frame 1 quiet mode [setting condition] specification by serirq transfer cycle stop frame sirqcr0 bit 6?eserved: this is a readable/writable reserved bit. sirqcr0 bit 5?nterrupt enable direct mode (iedir): specifies whether lpc channel 2 and channel 3 serirq interrupt source (smi, hirq6, hirq9 to hirq11) generation is conditional upon obf, or is controlled only by the host interrupt enable bit. bit 5 iedir description 0 host interrupt is requested when host interrupt enable bit and corresponding obf are both set to 1 (initial value) 1 host interrupt is requested when host interrupt enable bit is set to 1
597 sirqcr0 bit 4?mi interrupt enable 3b (smie3b): enables or disables a smi interrupt request when obf3b is set by a twr15 write. bit 4 smie3b description 0 smi interrupt request by obf3b and smie3b is disabled (initial value) [clearing conditions] ? writing 0 to smie3b ? lpc hardware reset, lpc software reset ? clearing obf3b to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf3b to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] ? writing 1 after reading smie3b = 0 sirqcr0 bit 3?mi interrupt enable 3a (smie3a): enables or disables a smi interrupt request when obf3a is set by an odr3 write. bit 3 smie3a description 0 smi interrupt request by obf3a and smie3a is disabled (initial value) [clearing conditions] ? writing 0 to smie3a ? lpc hardware reset, lpc software reset ? clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf3a to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] ? writing 1 after reading smie3a = 0
598 sirqcr1 bit 7?irq11 interrupt enable 3 (irq11e3): enables or disables a hirq11 interrupt request when obf3a is set by an odr3 write. bit 7 irq11e3 description 0 hirq11 interrupt request by obf3a and irq11e3 is disabled (initial value) [clearing conditions] ? writing 0 to irq11e3 ? lpc hardware reset, lpc software reset ? clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq11 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq11 interrupt is requested [setting condition] ? writing 1 after reading irq11e3 = 0 sirqcr1 bit 6?irq10 interrupt enable 3 (irq10e3): enables or disables a hirq10 interrupt request when obf3a is set by an odr3 write. bit 6 irq10e3 description 0 hirq10 interrupt request by obf3a and irq10e3 is disabled (initial value) [clearing conditions] ? writing 0 to irq10e3 ? lpc hardware reset, lpc software reset ? clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq10 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq10 interrupt is requested [setting condition] ? writing 1 after reading irq10e3 = 0
599 sirqcr1 bit 5?irq9 interrupt enable 3 (irq9e3): enables or disables a hirq9 interrupt request when obf3a is set by an odr3 write. bit 5 irq9e3 description 0 hirq9 interrupt request by obf3a and irq9e3 is disabled (initial value) [clearing conditions] ? writing 0 to irq9e3 ? lpc hardware reset, lpc software reset ? clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq9 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq9 interrupt is requested [setting condition] ? writing 1 after reading irq9e3 = 0 sirqcr1 bit 4?irq6 interrupt enable 3 (irq6e3): enables or disables a hirq6 interrupt request when obf3a is set by an odr3 write. bit 4 irq6e3 description 0 hirq6 interrupt request by obf3a and irq6e3 is disabled (initial value) [clearing conditions] ? writing 0 to irq6e3 ? lpc hardware reset, lpc software reset ? clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq6 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq6 interrupt is requested [setting condition] ? writing 1 after reading irq6e3 = 0
600 sirqcr0 bit 2?mi interrupt enable 2 (smie2): enables or disables a smi interrupt request when obf2 is set by an odr2 write. bit 2 smie2 description 0 smi interrupt request by obf2 and smie2 is disabled (initial value) [clearing conditions] ? writing 0 to smie2 ? lpc hardware reset, lpc software reset ? clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf2 to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] ? writing 1 after reading smie2 = 0 sirqcr1 bit 3?irq11 interrupt enable 2 (irq11e2): enables or disables a hirq11 interrupt request when obf2 is set by an odr2 write. bit 3 irq11e2 description 0 hirq11 interrupt request by obf2 and irq11e2 is disabled (initial value) [clearing conditions] ? writing 0 to irq11e2 ? lpc hardware reset, lpc software reset ? clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq11 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq11 interrupt is requested [setting condition] ? writing 1 after reading irq11e2 = 0
601 sirqcr1 bit 2?irq10 interrupt enable 2 (irq10e2): enables or disables a hirq10 interrupt request when obf2 is set by an odr2 write. bit 2 irq10e2 description 0 hirq10 interrupt request by obf2 and irq10e2 is disabled (initial value) [clearing conditions] ? writing 0 to irq10e2 ? lpc hardware reset, lpc software reset ? clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq10 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq10 interrupt is requested [setting condition] ? writing 1 after reading irq10e2 = 0 sirqcr1 bit 1?irq9 interrupt enable 2 (irq9e2): enables or disables a hirq9 interrupt request when obf2 is set by an odr2 write. bit 1 irq9e2 description 0 hirq9 interrupt request by obf2 and irq9e2 is disabled (initial value) [clearing conditions] ? writing 0 to irq9e2 ? lpc hardware reset, lpc software reset ? clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq9 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq9 interrupt is requested [setting condition] ? writing 1 after reading irq9e2 = 0
602 sirqcr1 bit 0?irq6 interrupt enable 2 (irq6e2): enables or disables a hirq6 interrupt request when obf2 is set by an odr2 write. bit 0 irq6e2 description 0 hirq6 interrupt request by obf2 and irq6e2 is disabled (initial value) [clearing conditions] ? writing 0 to irq6e2 ? lpc hardware reset, lpc software reset ? clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq6 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq6 interrupt is requested [setting condition] ? writing 1 after reading irq6e2 = 0 sirqcr0 bit 1?irq12 interrupt enable 1 (irq12e1): enables or disables a hirq12 interrupt request when obf1 is set by an odr1 write. bit 1 irq12e1 description 0 hirq12 interrupt request by obf1 and irq12e1 is disabled (initial value) [clearing conditions] ? writing 0 to irq12e1 ? lpc hardware reset, lpc software reset ? clearing obf1 to 0 1 hirq12 interrupt request by setting obf1 to 1 is enabled [setting condition] ? writing 1 after reading irq12e1 = 0
603 sirqcr0 bit 0?irq1 interrupt enable 1 (irq1e1): enables or disables a hirq1 interrupt request when obf1 is set by an odr1 write. bit 0 irq1e1 description 0 hirq1 interrupt request by obf1 and irq1e1 is disabled (initial value) [clearing conditions] ? writing 0 to irq1e1 ? lpc hardware reset, lpc software reset ? clearing obf1 to 0 1 hirq1 interrupt request by setting obf1 to 1 is enabled [setting condition] ? writing 1 after reading irq1e1 = 0 18b.2.10 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp0 bit is set to 1, the host interface (hif: lpc) halts and enters module stop mode. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrl bit 0?odule stop (mstp0): specifies host inteface (hif:lpc) module stop mode. mstpcrl bit 0 mstp0 description 0 hif:lpc module stop mode is cleared 1 hif:lpc module stop mode is set (initial value)
604 18b.3 operation 18b.3.1 host interface activation the host interface is activated by setting at least one of hicr0 bits lpc3e to lpc1e (bits 7 to 5) to 1 in single-chip mode. when the host interface is activated, the related i/o ports (ports 37 to 30, ports 83 and 82) function as dedicated host interface input/output pins. in addition, setting the fga20e, pmee, lsmie, and lscie bits to 1 adds the related i/o ports (ports 81 and 80, ports b0 and b1) to the host interface? input/output pins. use the following procedure to activate the host interface after a reset release. 1. read the signal line status and confirm that the lpc module can be connected. also check that the lpc module is initialized internally. 2. when using channel 3, set ladr3 to determine the channel 3 i/o address and whether two- way registers are to be used. 3. set the enable bit (lpc3e to lpc1e) for the channel to be used. 4. set the enable bits (ga20e, pmee, lsmie, and lscie) for the additional functions to be used. 5. set the selection bits for other functions (sdwne, iedir). 6. as a precaution, clear the interrupt flags (lrst, sdwn, abrt, obf). read idr or twr15 to clear ibf. 7. set interrupt enable bits (ibfie3 to ibfie1, errie) as necessary. 18b.3.2 lpc i/o cycles there are ten kinds of lpc transfer cycle: memory read, memory write, i/o read, i/o write, dma read, dma write, bus master memory read, bus master memory write, bus master i/o read, and bus master i/o write. of these, the chip's hif:lpc supports only i/o read and i/o write cycles. an lpc transfer cycle is started when the lframe signal goes low in the bus idle state. if the lframe signal goes low when the bus is not idle, this means that a forced termination (abort) of the lpc transfer cycle has been requested. in an i/o read cycle or i/o write cycle, transfer is carried out using lad3 to lad0 in the following order, in synchronization with lclk. the host can be made to wait by sending back a value other than 0000 in the slave?s synchronization return cycle, but with the h8s/2149?s hif:lpc a value of 0000 is always returned. if the received address matches the host address in an hif:lpc register (idr, odr, str, twr), the host interface enters the busy state; it returns to the idle state by output of a state #12 turnaround. register (idr, etc.) and flag (ibf, etc.) changes are made at this timing, so in the
605 event of a transfer cycle forced termination (abort) before state #12, registers and flags are not changed. i/o read cycle i/o write cycle state count contents drive source value (3 to 0) contents drive source value (3 to 0) 1 start host 0000 start host 0000 2 cycle type/direction host 0000 cycle type/direction host 0010 3 address 1 host bits 15 to 12 address 1 host bits 15 to 12 4 address 2 host bits 11 to 8 address 2 host bits 11 to 8 5 address 3 host bits 7 to 4 address 3 host bits 7 to 4 6 address 4 host bits 3 to 0 address 4 host bits 3 to 0 7 turnaround (recovery) host 1111 data 1 host bits 3 to 0 8 turnaround none zzzz data 2 host bits 7 to 4 9 synchronization slave 0000 turnaround (recovery) host 1111 10 data 1 slave bits 3 to 0 turnaround none zzzz 11 data 2 slave bits 7 to 4 synchronization slave 0000 12 turnaround (recovery) slave 1111 turnaround (recovery) slave 1111 13 turnaround none zzzz turnaround none zzzz the timing of the lframe , lclk, and lad signals is shown in figures 18b.2 and 18b.3. addr start lframe lad3?ad0 number of clocks lclk tar sync data tar start cycle type, direction, and size 114 1 2221 figure 18b.2 typical lframe timing
606 addr start lframe lad3?ad0 lclk tar sync cycle type, direction, and size slave must stop driving too many syncs cause timeout master will drive high figure 18b.3 abort mechanism 18b.3.3 a20 gate the a20 gate signal can mask address a20 to emulate an addressing mode used by personal computers with an 8086*-family cpu. a regular-speed a20 gate signal can be output under firmware control. fast a20 gate output is enabled by setting the fga20e bit (bit 4) to 1 in hicr0 (h'fe40). note: * an intel microprocessor regular a20 gate operation: output of the a20 gate signal can be controlled by an h'd1 command followed by data. when the slave processor (h8s/2149) receives data, it normally uses an interrupt routine activated by the ibf1 interrupt to read idr1. if the data follows an h'd1 command, firmware copies bit 1 of the data and outputs it at the gate a20 pin. fast a20 gate operation: when the fga20e bit is set to 1, p81/ga20 is used for output of a fast a20 gate signal. bit p81ddr must be set to 1 to assign this pin for output. when the ddr bit for p81 is set to 1, the state of the p81/ga20 pin can be monitored by reading the ga20 bit in hicr2. the initial output from this pin will be a logic 1, which is the initial value. afterward, the host processor can manipulate the output from this pin by sending commands and data. this function is only available via the idr1 register. the host interface decodes commands input from the host. when an h'd1 host command is detected, bit 1 of the data following the host command is output from the ga20 output pin. this operation does not depend on firmware or interrupts, and is faster than the regular processing using interrupts. table 18b.3 shows the conditions that set and clear ga20 (p81). figure 18b.4 shows the ga20 output in flowchart form. table 18b.4 indicates the ga20 output signal values.
607 table 18b.3 ga20 (p81) set/clear timing pin name setting condition clearing condition ga20 (p81) when bit 1 of the written data is 1 and data follows an h'd1 host command when bit 1 of the written data is 0 and the data follows an h'd1 host command start wait for next byte h'd1 command received? host write host write yes no data byte? no write bit 1 of data byte to dr bit of p81/ga20 yes figure 18b.4 ga20 output
608 table 18b.4 fast a20 gate output signals ha0 data/command internal cpu interrupt flag (ibf) ga20 (p81) remarks 1 h'd1 command 0 q turn-on sequence 0 1 data * 1 01 1 h'ff command 0 q (1) 1 h'd1 command 0 q turn-off sequence 0 0 data * 2 00 1 h'ff command 0 q (0) 1 h'd1 command 0 q turn-on sequence 0 1 data * 1 01 (abbreviated form) 1/0 command other than h'ff and h'd1 1 q (1) 1 h'd1 command 0 q turn-off sequence 0 0 data * 2 00 (abbreviated form) 1/0 command other than h'ff and h'd1 1 q (0) 1 1 h'd1 command command other than h'd1 0 1 q q cancelled sequence 1 h'd1 command 0 q retriggered sequence 1 h'd1 command 0 q 1 h'd1 command 0 q consecutively executed 0 any data 0 1/0 sequences 1 h'd1 command 0 q (1/0) notes: 1. arbitrary data with bit 1 set to 1. 2. arbitrary data with bit 1 cleard to 0.
609 18b.3.4 host interface shutdown function (lpcpd) the host interface can be placed in the shutdown state according to the state of the lpcpd pin. there are two kinds of host interface shutdown state: lpc hardware shutdown and lpc software shutdown. the lpc hardware shutdown state is controlled by the lpcpd pin, while the software shutdown state is controlled by the sdwnb bit. in both states, the host interface enters the reset state by itself, and is no longer affected by external signals other than the lreset and lpcpd signals. placing the slave processor in sleep mode or software standby mode is effective in reducing current dissipation in the shutdown state. if software standby mode is set, some means must be provided for exiting software standby mode before clearing the shutdown state with the lpcpd signal. if the sdwne bit has been set to 1 beforehand, the lpc hardware shutdown state is entered at the same time as the lpcpd signal falls, and prior preparation is not possible. if the lpc software shutdown state is set by means of the sdwnb bit, on the other hand, the lpc software shutdown state cannot be cleared at the same time as the rise of the lpcpd signal. taking these points into consideration, the following operating procedure uses a combination of lpc software shutdown and lpc hardware shutdown. 1. clear the sdwne bit to 0. 2. set the errie bit to 1 and wait for an interrupt by the sdwn flag. 3. when an erri interrupt is generated by the sdwn flag, check the host interface internal status flags and perform any necessary processing. 4. set the sdwnb bit to 1 to set lpc software standby mode. 5. set the sdwne bit to 1 and make a transition to lpc hardware standby mode. the sdwnb bit is cleared automatically. 6. check the state of the lpcpd signal to make sure that the lpcpd signal has not risen during steps 3 to 5. if the signal has risen, clear sdwne to 0 to return to the state in step 1. 7. place the slave processor in sleep mode or software standby mode as necessary. 8'. if software standby mode has been set, exit software standby mode by some means independent of the lpc. 8. when a rising edge is detected in the lpcpd signal, the sdwne bit is automatically cleared to 0. if the slave processor has been placed in sleep mode, the mode is exited by means of lreset signal input, on completion of the lpc transfer cycle, or by some other means. table 18b.5 shows the scope of hif pin shutdown
610 table 18b.5 scope of hif pin shutdown abbreviation port scope of shutdown i/o notes lad3 to lad0 p33?30 o i/o hi-z lframe p34 o input hi-z lreset p35 x input lpc hardware reset function is active lclk p36 o input hi-z serirq p37 o i/o hi-z lsci pb1 d i/o hi-z, only when lscie = 1 lsmi pb0 d i/o hi-z, only when lsmie = 1 pme p80 d i/o hi-z, only when pmee = 1 ga20 p81 d i/o hi-z, only when fga20e = 1 clkrun p82 o i/o hi-z lpcpd p83 x input needed to clear shutdown state note: o: pins shut down by the shutdown function d : pins shut down only when the hif (lpc) function is selected by register setting x: pins not shut down in the lpc shutdown state, the lpc?s internal state and some register bits are initialized. the order of priority of lpc shutdown and reset states is as follows. 1. system reset (reset by stby or res pin input, or wdt0 overflow) all register bits, including bits lpc3e to lpc1e, are initialized. 2. lpc hardware reset (reset by lreset pin input) lrstb, sdwne, and sdwnb bits are cleared to 0. 3. lpc software reset (reset by lrstb) sdwne and sdwnb bits are cleared to 0. 4. lpc hardware shutdown sdwnb bit is cleared to 0. 5. lpc software shutdown the scope of the initialization in each mode is shown in table 18b.6.
611 table 18b.6 scope of initialization in each host interface mode items initialized system reset lpc reset lpc shutdown lpc transfer cycle sequencer (internal state), lpcbsy and abrt flags initialized initialized initialized serirq transfer cycle sequencer (internal state), clkreq and irqbsy flags initialized initialized initialized host interface flags (ibf1, ibf2, ibf3a, ibf3b, mwmf, c/ d 1, c/ d 2, c/ d 3, obf1, obf2, obf3a, obf3b, swmf, dbu), ga20 (internal state) initialized initialized retained host interrupt enable bits (irq1e1, irq12e1, smie2, irq6e2, irq9e2 to irq11e2, smie3b, smie3a, irq6e3, irq9e3 to irq11e3), q/ c flag initialized initialized retained lrst flag initialized (0) can be set/cleared can be set/cleared sdwn flag initialized (0) initialized (0) can be set/cleared lrstb bit initialized (0) hr: 0 sr: 1 0 (can be set) sdwnb bit initialized (0) initialized (0) hs: 0 ss: 1 sdwne bit initialized (0) initialized (0) hs: 1 ss: 0 or 1 host interface operation control bits (lpc3e to lpc1e, fga20e, ladr3, ibfie1 to ibfie3, pmee, pmeb, lsmie, lsmib, lscie, lscib) initialized retained retained lreset signal input (port input input lpcpd signal function) input input lad3 to lad0, lframe , lclk, serirq, clkrun signals input hi-z pme , lsmi , lsci, ga20 signals (when function is selected) output hi-z pme , lsmi , lsci, ga20 signals (when function is not selected) port function port function note: system reset: reset by stby input, res input, or wdt overflow lpc reset: reset by lpc hardware reset (hr) or lpc software reset (sr) lpc shutdown: reset by lpc hardware shutdown (hs) or lpc software shutdown (ss)
612 figure 18b.5 shows the timing of the lpcpd and lreset signals. lpcpd lreset lad3?ad0 lframe lclk at least 30 m s at least 100 m s at least 60 m s figure 18b.5 power-down state termination timing 18b.3.5 host interface serialized interrupt operation (serirq) a host interrupt request can be issued from the host interface by means of the serirq pin. in a host interrupt request via the serirq pin, lclk cycles are counted from the start frame of the serialized interrupt transfer cycle generated by the host or a supporting function, and a request signal is generated by the frame corresponding to that interrupt. the timing is shown in figure 18b.6.
613 irq1 irq1 host controller none none serirq drive source lclk start start frame irq0 frame irq1 frame irq2 frame sl or h hrtr st r st r st irq15 host controller none none serirq driver lclk start stop iochck frame stop frame next cycle irq14 frame irq15 frame r st r st r st rt h i h = host control, sl = slave control, r = recovery, t = turnaround, s = sample h = host control, r = recover y , t = turnaround, s = sample, i = idle figure 18b.6 serirq timing the serialized interrupt transfer cycle frame configuration is as follows. two of the states comprising each frame are the recover state in which the serirq signal is returned to the 1-level at the end of the frame, and the turnaround state in which the serirq signal is not driven. the recover state must be driven by the host or slave processor that was driving the preceding state.
614 serial interrupt transfer cycle frame count contents drive source number of states notes 0 start slave host 6 in quiet mode only, slave drive possible in first state, then next 3 states 0-driven by host 1 hirq0 slave 3 2 hirq1 slave 3 drive possible in lpc channel 1 3 smi slave 3 drive possible in lpc channels 2 and 3 4 hirq3 slave 3 5 hirq4 slave 3 6 hirq5 slave 3 7 hirq6 slave 3 drive possible in lpc channels 2 and 3 8 hirq7 slave 3 9 hirq8 slave 3 10 hirq9 slave 3 drive possible in lpc channels 2 and 3 11 hirq10 slave 3 drive possible in lpc channels 2 and 3 12 hirq11 slave 3 drive possible in lpc channels 2 and 3 13 hirq12 slave 3 drive possible in lpc channel 1 14 hirq13 slave 3 15 hirq14 slave 3 16 hirq15 slave 3 17 iochck slave 3 18 stop host undefined first, 1 or more idle states, then 2 or 3 states 0-driven by host 2 states: quiet mode next 3 states: continuous mode next there are two modes?continuous mode and quiet mode?for serialized interrupts. the mode initiated in the next transfer cycle is selected by the stop frame of the serialized interrupt transfer cycle that ended before that cycle. in continuous mode, the host initiates host interrupt transfer cycles at regular intervals. in quiet mode, the slave processor with interrupt sources requiring a request can also initiate an interrupt transfer cycle, in addition to the host. in quiet mode, since the host does not necessarily initiate interrupt transfer cycles, it is possible to suspend the clock (lclk) supply and enter the power- down state. in order for a slave to transfer an interrupt request in this case, a request to restart the clock must first be issued to the host. for details see section 18b.3.6, host interface clock start request (clkrun).
615 18b.3.6 host interface clock start request (clkrun) a request to restart the clock (lclk) can be sent to the host processor by means of the clkrun pin. with lpc data transfer and serirq in continuous mode, a clock restart is never requested since the transfer cycles are initiated by the host. with serirq in quiet mode, when a host interrupt request is generated the clkrun signal is driven and a clock (lclk) restart request is sent to the host. the timing for this operation is shown in figure 18b.7. clk clkrun pull-up enable drive by the host processor drive by the slave processor 1 2 3 4 5 6 figure 18b.7 clock start or speed-up cases other than serirq in quiet mode when clock restart is required must be handled with a different protocol, using the pme signal, etc.
616 18b.4 interrupt sources 18b.4.1 ibf1, ibf2, ibf3, erri the host interface has four interrupt requests for the slave processor: ibf1, ibf2, ibf3, and erri. ibf1, ibf2, and ibf3 are idr receive complete interrupts for idr1, idr2, and idr3 and twr, respectively. the erri interrupt indicates the occurrence of a special state such as an lpc reset, lpc shutdown, or transfer cycle abort. an interrupt request is enable by setting the corresponding enable bit, table 18b.7 receive complete interrupts and error interrupt interrupt description ibf1 requested when ibfie1 is set to 1 and idr1 reception is completed ibf2 requested when ibfie2 is set to 1 and idr2 reception is completed ibf3 requested when ibfie3 is set to 1 and idr3 reception is completed, or when twre and ibfie3 are set to 1 and reception is completed up to twr15 erri requested when errie is set to 1 and lrst, sdwn, or abrt is set to 1 18b.4.2 smi, hirq1, hirq6, hirq9, hirq10, hirq11, hirq12 the host interface can request seven kinds of host interrupt by means of serirq. hirq1 and hirq12 are used on lpc channel 1 only, while smi, hirq6, hirq9, hirq10, and hirq11 can be requested from lpc channel 2 or 3. there are two ways of clearing a host interrupt request. when the iedir bit is cleared to 0 in sirqcr0, host interrupt sources and lpc channels are all linked to the host interrupt request enable bits. when the obf flag is cleared to 0 by a read by the host of odr or twr15 in the corresponding lpc channel, the corresponding host interrupt enable bit is automatically cleared to 0, and the host interrupt request is cleared. when the iedir bit is set to 1 in sirqcr0, lpc channel 2 and 3 interrupt requests are dependent only upon the host interrupt enable bits. the host interrupt enable bit is not cleared when obf for channel 2 or 3 is cleared. therefore, smie2, smie3a and smie3b, irq6e2 and irq6e3, irq9e2 and irq9e3, irq10e2 and irq10e3, and irq11e2 and irq11e3 lose their respective functional differences. in order to clear a host interrupt request, it is necessary to clear the host interrupt enable bit. table 18b.8 summarizes the methods of setting and clearing these bits, and figure 18b.8 shows the processing flowchart.
617 table 18b.8 hirq setting and clearing conditions host interrupt setting condition clearing condition hirq1 (independent from iedir) internal cpu writes to odr1, then reads 0 from bit irq1e1 and writes 1 internal cpu writes 0 in bit irq1e1, or host reads odr1 hirq12 (independent from iedir) internal cpu writes to odr1, then reads 0 from bit irq12e1 and writes 1 internal cpu writes 0 in bit irq12e1, or host reads odr1 smi (iedir = 0) internal cpu writes to odr2, then reads 0 from bit smie2 and writes 1 writes to odr3, then reads 0 from bit smie3a and writes 1 writes to twr15, then reads 0 from bit smie3b and writes 1 internal cpu writes 0 in bit smie2, or host reads odr2 internal cpu writes 0 in bit smie3a, or host reads odr3 internal cpu writes 0 in bit smie3b, or host reads twr15 smi (iedir = 1) internal cpu reads 0 from bit smie2, then writes 1 reads 0 from bit smie3a, then writes 1 reads 0 from bit smie3b, then writes 1 internal cpu writes 0 in bit smie2 internal cpu writes 0 in bit smie3a internal cpu writes 0 in bit smie3b hirqi (i = 6, 9, 10, 11) (iedir = 0) internal cpu writes to odr2, then reads 0 from bit irqie2 and writes 1 writes to odr3, then reads 0 from bit irqie3 and writes 1 internal cpu writes 0 in bit irqie2, or host reads odr2 internal cpu writes 0 in bit irqie3, or host reads odr3 hirqi (i = 6, 9, 10, 11) (iedir = 1) internal cpu reads 0 from bit irqie2, then writes 1 reads 0 from bit irqie3, then writes 1 internal cpu writes 0 in bit irqie2 internal cpu writes 0 in bit irqie3
618 slave cpu master cpu odr1 write write 1 to irq1e1 obf1 = 0? yes no no yes all bytes transferred? serirq irq1 output serirq irq1 source clearance interrupt initiation odr1 read hardware operation software operation figure 18b.8 hirq flowchart (example of channel 1) 18b.5 usage note the following points should be noted when using the hif : lpc. (1) the host interface provides buffering of asynchronous data from the host processor and slave processor, but an interface protocol that uses the flags in str must be followed to avoid data contention. for example, if the host and slave processor both try to access idr or odr at the same time, the data will be corrupted. to prevent simultaneous accesses, ibf and obf must be used to allow access only to data for which writing has finished. (2) unlike the idr and odr registers, the transfer direction is not fixed for the two-way registers (twr). mwmf and swmf are provided in str to handle this situation. after writing to twr0, mwmf and swmf must be used to confirm that the write authority for twr1 to twr15 has been obtained. (3) table 18b.9 shows host address examples for corresponding registers when ladr3 = h'a24f and ladr3 = h'3fd0.
619 table 18b.9 host address example register host address when ladr3 = h'a24f host address when ladr3 = h'3fd0 idr3 h'a24a and h'a24e h'3fd0 and h'3fd4 odr3 h'a24a h'3fd0 str3 h'a24e h'3fd4 twr0mw h'a250 h'3fc0 twr0sw h'a250 h'3fc0 twr1 h'a251 h'3fc1 twr2 h'a252 h'3fc2 twr3 h'a253 h'3fc3 twr4 h'a254 h'3fc4 twr5 h'a255 h'3fc5 twr6 h'a256 h'3fc6 twr7 h'a257 h'3fc7 twr8 h'a258 h'3fc8 twr9 h'a259 h'3fc9 twr10 h'a25a h'3fca twr11 h'a25b h'3fcb twr12 h'a25c h'3fcc twr13 h'a25d h'3fcd twr14 h'a25e h'3fce twr15 h'a25f h'3fcf
620
621 section 19 d/a converter 19.1 overview the h8s/2169 or h8s/2149 has an on-chip d/a converter module with two channels. 19.1.1 features features of the d/a converter module are listed below. ? eight-bit resolution ? two-channel output ? maximum conversion time: 10 m s (with 20-pf load capacitance) ? output voltage: 0 v to av ref ? d/a output retention in software standby mode 19.1.2 block diagram figure 19.1 shows a block diagram of the d/a converter.
622 bus interface module data bus internal data bus 8-bit d/a dadr0 dadr1 dacr control circuit avref avcc da0 da1 avss legend: dacr: dadr0: dadr1: d/a control register d/a data register 0 d/a data register 1 figure 19.1 block diagram of d/a converter
623 19.1.3 input and output pins table 19.1 lists the input and output pins used by the d/a converter module. table 19.1 input and output pins of d/a converter module name abbreviation i/o function analog supply voltage avcc input power supply for analog circuits analog ground avss input ground and reference voltage for analog circuits analog output 0 da0 output analog output channel 0 analog output 1 da1 output analog output channel 1 reference voltage pin avref input reference voltage for analog circuits 19.1.4 register configuration table 19.2 lists the registers of the d/a converter module. table 19.2 d/a converter registers name abbreviation r/w initial value address * d/a data register 0 dadr0 r/w h'00 h'fff8 d/a data register 1 dadr1 r/w h'00 h'fff9 d/a control register dacr r/w h'1f h'fffa module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 note: * lower 16 bits of the address.
624 19.2 register descriptions 19.2.1 d/a data registers 0 and 1 (dadr0, dadr1) bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w d/a data registers 0 and 1 (dadr0 and dadr1) are 8-bit readable/writable registers that store data to be converted. when analog output is enabled, the value in the d/a data register is converted and output continuously at the analog output pin. the d/a data registers are initialized to h'00 by a reset and in hardware standby mode. 19.2.2 d/a control register (dacr) bit initial value read/write 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 1 3 1 0 1 2 1 1 1 dacr is an 8-bit readable/writable register that controls the operation of the d/a converter module. dacr is initialized to h'1f by a reset and in hardware standby mode. bit 7?/a output enable 1 (daoe1): controls d/a conversion and analog output. bit 7 daoe1 description 0 analog output da1 is disabled (initial value) 1 d/a conversion is enabled on channel 1. analog output da1 is enabled
625 bit 6?/a output enable 0 (daoe0): controls d/a conversion and analog output. bit 6 daoe0 description 0 analog output da0 is disabled (initial value) 1 d/a conversion is enabled on channel 0. analog output da0 is enabled bit 5?/a enable (dae): controls d/a conversion, in combination with bits daoe0 and daoe1. d/a conversion is controlled independently on channels 0 and 1 when dae = 0. channels 0 and 1 are controlled together when dae = 1. output of the converted results is always controlled independently by daoe0 and daoe1. bit 7 bit 6 bit 5 daoe1 daoe0 dae d/a conversion 00 * disabled on channels 0 and 1 1 0 enabled on channel 0 disabled on channel 1 1 enabled on channels 0 and 1 1 0 0 disabled on channel 0 enabled on channel 1 1 enabled on channels 0 and 1 1 * enabled on channels 0 and 1 * : don? care if the chip enters software standby mode while d/a conversion is enabled, the d/a output is retained and the analog power supply current is the same as during d/a conversion. if it is necessary to reduce the analog power supply current in software standby mode, disable d/a output by clearing the daoe0, daoe1 and dae bits to 0. bits 4 to 0?eserved: these bits cannot be modified and are always read as 1.
626 19.2.3 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp10 bit is set to 1, the d/a converter halts and enters module stop mode at the end of the bus cycle. see section 24.5, module stop mode, for details. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 2?odule stop (mstp10): specifies d/a converter module stop mode. mstpcrh bit 2 mstp10 description 0 d/a converter module stop mode is cleared 1 d/a converter module stop mode is set (initial value)
627 19.3 operation the d/a converter module has two built-in d/a converter circuits that can operate independently. d/a conversion is performed continuously whenever enabled by the d/a control register (dacr). when a new value is written in dadr0 or dadr1, conversion of the new value begins immediately. the converted result is output by setting the daoe0 or daoe1 bit to 1. an example of conversion on channel 0 is given next. figure 19.2 shows the timing. ? software writes the data to be converted in dadr0. ? d/a conversion begins when the daoe0 bit in dacr is set to 1. after the elapse of the conversion time, analog output appears at the da0 pin. the output value is avref (dadr value)/256. this output continues until a new value is written in dadr0 or the daoe0 bit is cleared to 0. ? if a new value is written in dadr0, conversion begins immediately. output of the converted result begins after the conversion time. ? when the daoe0 bit is cleared to 0, da0 becomes an input pin. dadr0 write cycle dacr write cycle dadr0 write cycle dacr write cycle address dadr0 daoe0 da0 conversion data (1) conversion data (2) high-impedance state conversion result (1) conversion result (2) t dconv t dconv t : d/a conversion time dconv figure 19.2 d/a conversion (example)
628
629 section 20 a/d converter 20.1 overview the h8s/2169 or h8s/2149 incorporates a 10-bit successive-approximations a/d converter that allows up to eight analog input channels to be selected. in addition to the eight analog input channels, up to 16 channels of digital input can be selected for a/d conversion. since the conversion precision falls when digital input is selected, digital input is ideal for use by a comparator identifying multi-valued inputs, for example. 20.1.1 features a/d converter features are listed below. ? 10-bit resolution ? eight (analog) or 16 (digital) input channels ? settable analog conversion voltage range ? the analog conversion voltage range is set using the reference power supply voltage pin (avref) as the analog reference voltage ? high-speed conversion ? minimum conversion time: 13.4 m s per channel (at 10 mhz operation) ? choice of single mode or scan mode ? single mode: single-channel a/d conversion ? scan mode: continuous a/d conversion on 1 to 4 channels ? four data registers ? conversion results are held in a 16-bit data register for each channel ? sample and hold function ? three kinds of conversion start ? choice of software or timer conversion start trigger (8-bit timer), or adtrg pin a/d conversion end interrupt generation ? an a/d conversion end interrupt (adi) request can be generated at the end of a/d conversion
630 20.1.2 block diagram figure 20.1 shows a block diagram of the a/d converter. module data bus control circuit internal data bus 10-bit d/a comparator + sample-and- hold circuit ?8 ?16 adi interrupt signal bus interface adcsr adcr addrd addrc addrb addra avcc avref avss an0 an1 an2 an3 an4 an5 an6/cin0 to cin7 an7/cin8 to cin15 adtrg conversion start trigger from 8-bit timer successive approximations register multiplexer legend: adcr: a/d control register adcsr: a/d control/status register addra: a/d data register a addrb: a/d data register b addrc: a/d data register c addrd: a/d data register d figure 20.1 block diagram of a/d converter
631 20.1.3 pin configuration table 20.1 summarizes the input pins used by the a/d converter. the avcc and avss pins are the power supply pins for the analog block in the a/d converter. table 20.1 a/d converter pins pin name symbol i/o function analog power supply pin avcc input analog block power supply analog ground pin avss input analog block ground and a/d conversion reference voltage reference power supply pin avref input a/d conversion reference voltage analog input pin 0 an0 input analog input channel 0 analog input pin 1 an1 input analog input channel 1 analog input pin 2 an2 input analog input channel 2 analog input pin 3 an3 input analog input channel 3 analog input pin 4 an4 input analog input channel 4 analog input pin 5 an5 input analog input channel 5 analog input pin 6 an6 input analog input channel 6 analog input pin 7 an7 input analog input channel 7 a/d external trigger input pin adtrg input external trigger input for starting a/d conversion expansion a/d input pins 0 to 15 cin0 to cin15 input expansion a/d conversion input (digital input pin) channels 0 to 15
632 20.1.4 register configuration table 20.2 summarizes the registers of the a/d converter. table 20.2 a/d converter registers name abbreviation r/w initial value address * 1 a/d data register ah addrah r h'00 h'ffe0 a/d data register al addral r h'00 h'ffe1 a/d data register bh addrbh r h'00 h'ffe2 a/d data register bl addrbl r h'00 h'ffe3 a/d data register ch addrch r h'00 h'ffe4 a/d data register cl addrcl r h'00 h'ffe5 a/d data register dh addrdh r h'00 h'ffe6 a/d data register dl addrdl r h'00 h'ffe7 a/d control/status register adcsr r/(w) * 2 h'00 h'ffe8 a/d control register adcr r/w h'3f h'ffe9 module stop control register mstpcrh r/w h'3f h'ff86 mstpcrl r/w h'ff h'ff87 keyboard comparator control register kbcomp r/w h'00 h'fee4 notes: 1. lower 16 bits of the address. 2. only 0 can be written in bit 7, to clear the flag. 20.2 register descriptions 20.2.1 a/d data registers a to d (addra to addrd) 15 ad9 0 r bit initial value read/write 14 ad8 0 r 13 ad7 0 r 12 ad6 0 r 11 ad5 0 r 10 ad4 0 r 9 ad3 0 r 8 ad2 0 r 7 ad1 0 r 6 ad0 0 r 5 0 r 4 0 r 3 0 r 2 0 r 1 0 r 0 0 r there are four 16-bit read-only addr registers, addra to addrd, used to store the results of a/d conversion.
633 the 10-bit data resulting from a/d conversion is transferred to the addr register for the selected channel and stored there. the upper 8 bits of the converted data are transferred to the upper byte (bits 15 to 8) of addr, and the lower 2 bits are transferred to the lower byte (bits 7 and 6) and stored. bits 5 to 0 are always read as 0. the correspondence between the analog input channels and addr registers is shown in table 20.3. the addr registers can always be read by the cpu. the upper byte can be read directly, but for the lower byte, data transfer is performed via a temporary register (temp). for details, see section 20.3, interface to bus master. the addr registers are initialized to h'0000 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. table 20.3 analog input channels and corresponding addr registers analog input channel group 0 group 1 a/d data register an0 an4 addra an1 an5 addrb an2 an6 or cin0 to cin7 addrc an3 an7 or cin8 to cin15 addrd 20.2.2 a/d control/status register (adcsr) 7 adf 0 r/(w) * 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w bit initial value read/write note: * only 0 can be written in bit 7, to clear the flag. adcsr is an 8-bit readable/writable register that controls a/d conversion operations. adcsr is initialized to h'00 by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode.
634 bit 7?/d end flag (adf): status flag that indicates the end of a/d conversion. bit 7 adf description 0 [clearing conditions] (initial value) ? when 0 is written in the adf flag after reading adf = 1 ? when the dtc is activated by an adi interrupt and addr is read 1 [setting conditions] ? single mode: when a/d conversion ends ? scan mode: when a/d conversion ends on all specified channels bit 6?/d interrupt enable (adie): selects enabling or disabling of interrupt (adi) requests at the end of a/d conversion. bit 6 adie description 0 a/d conversion end interrupt (adi) request is disabled (initial value) 1 a/d conversion end interrupt (adi) request is enabled bit 5?/d start (adst): selects starting or stopping of a/d conversion. holds a value of 1 during a/d conversion. the adst bit can be set to 1 by software, a timer conversion start trigger, or the a/d external trigger input pin ( adtrg ). bit 5 adst description 0 a/d conversion stopped (initial value) 1 single mode: a/d conversion is started. cleared to 0 automatically when conversion on the specified channel ends scan mode: a/d conversion is started. conversion continues sequentially on the selected channels until adst is cleared to 0 by software, a reset, or a transition to standby mode or module stop mode bit 4?can mode (scan): selects single mode or scan mode as the a/d conversion operating mode. see section 20.4, operation, for single mode and scan mode operation. only set the scan bit while conversion is stopped.
635 bit 4 scan description 0 single mode (initial value) 1 scan mode bit 3?lock select (cks): sets the a/d conversion time. only change the conversion time while adst = 0. bit 3 cks description 0 conversion time = 266 states (max.) (initial value) 1 conversion time = 134 states (max.) bits 2 to 0?hannel select 2 to 0 (ch2 to ch0): together with the scan bit, these bits select the analog input channel(s). two analog input channel can be switched to digital input. only set the input channel while conversion is stopped. group selection channel selection description ch2 ch1 ch0 single mode scan mode 0 0 0 an0 (initial value) an0 1 an1 an0, an1 1 0 an2 an0 to an2 1 an3 an0 to an3 1 0 0 an4 an4 1 an5 an4, an5 1 0 an6 or cin0 to cin7 an4, an5, an6 or cin0 to cin7 1 an7 or cin8 to cin15 an4, an5, an6 or cin0 to cin7 an7 or cin8 to cin15
636 20.2.3 a/d control register (adcr) 7 trgs1 0 r/w 6 trgs0 0 r/w 5 1 4 1 3 1 0 1 2 1 1 1 bit initial value read/write adcr is an 8-bit readable/writable register that enables or disables external triggering of a/d conversion operations. adcr is initialized to h'3f by a reset, and in standby mode, watch mode, subactive mode, subsleep mode, and module stop mode. bits 7 and 6?imer trigger select 1 and 0 (trgs1, trgs0): these bits select enabling or disabling of the start of a/d conversion by a trigger signal. only set bits trgs1 and trgs0 while conversion is stopped. bit 7 bit 6 trgs1 trgs0 description 0 0 start of a/d conversion by external trigger is disabled (initial value) 1 start of a/d conversion by external trigger is disabled 1 0 start of a/d conversion by external trigger (8-bit timer) is enabled 1 start of a/d conversion by external trigger pin is enabled bits 5 to 0?eserved: should always be written with 1.
637 20.2.4 keyboard comparator control register (kbcomp) bit 76543210 ire ircks2 ircks1 ircks0 kbade kbch2 kbch1 kbch0 initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w kbcomp is an 8-bit readable/writable register that controls the sci2 irda function and selects the cin input channels for a/d conversion. kbcomp is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4?rda control: see the description in section 15.2.11, keyboard comparator control register (kbcomp). bit 3?eyboard a/d enable (kbade): selects either analog input pins (an6, an7) or digital input pins (cin0 to cin7, cin8 to cin15) for a/d converter channel 6 and channel 7 input. bits 2 to 0?eyboard a/d channel select 2 to 0 (kbch2 to kbch0): these bits select the channels for a/d conversion from among the digital input pins. only set the input channel while a/d conversion is stopped. bit 3 bit 2 bit 1 bit 0 kbade kbch2 kbch1 kbch0 a/d converter channel 6 input a/d converter channel 7 input 0 an6 an7 1 0 0 0 cin0 cin8 1 cin1 cin9 1 0 cin2 cin10 1 cin3 cin11 1 0 0 cin4 cin12 1 cin5 cin13 1 0 cin6 cin14 1 cin7 cin15
638 20.2.5 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr, comprising two 8-bit readable/writable registers, performs module stop mode control. when the mstp9 bit in mstpcr is set to 1, a/d converter operation stops at the end of the bus cycle and a transition is made to module stop mode. registers cannot be read or written to in module stop mode. for details, see section 24.5, module stop mode. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode. mstpcrh bit 1?odule stop (mstp9): specifies the a/d converter module stop mode. mstpcrh bit 1 mstp9 description 0 a/d converter module stop mode is cleared 1 a/d converter module stop mode is set (initial value)
639 20.3 interface to bus master addra to addrd are 16-bit registers, but the data bus to the bus master is only 8 bits wide. therefore, in accesses by the bus master, the upper byte is accessed directly, but the lower byte is accessed via a temporary register (temp). a data read from addr is performed as follows. when the upper byte is read, the upper byte value is transferred to the cpu and the lower byte value is transferred to temp. next, when the lower byte is read, the temp contents are transferred to the cpu. when reading addr, always read the upper byte before the lower byte. it is possible to read only the upper byte, but if only the lower byte is read, incorrect data may be obtained. figure 20.2 shows the data flow for addr access. bus master (h'aa) addrnh (h'aa) addrnl (h'40) lower byte read addrnh (h'aa) addrnl (h'40) temp (h'40) temp (h'40) (n = a to d) (n = a to d) module data bus module data bus bus interface upper byte read bus master (h'40) bus interface figure 20.2 addr access operation (reading h'aa40)
640 20.4 operation the a/d converter operates by successive approximations with 10-bit resolution. it has two operating modes: single mode and scan mode. 20.4.1 single mode (scan = 0) single mode is selected when a/d conversion is to be performed on a single channel only. a/d conversion is started when the adst bit is set to 1 by software, or by external trigger input. the adst bit remains set to 1 during a/d conversion, and is automatically cleared to 0 when conversion ends. on completion of conversion, the adf flag is set to 1. if the adie bit is set to 1 at this time, an adi interrupt request is generated. the adf flag is cleared by writing 0 after reading adcsr. when the operating mode or analog input channel must be changed during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1 to start a/d conversion again. the adst bit can be set at the same time as the operating mode or input channel is changed. typical operations when channel 1 (an1) is selected in single mode are described next. figure 20.3 shows a timing diagram for this example. 1. single mode is selected (scan = 0), input channel an1 is selected (ch1 = 0, ch0 = 1), the a/d interrupt is enabled (adie = 1), and a/d conversion is started (adst = 1). 2. when a/d conversion is completed, the result is transferred to addrb. at the same time the adf flag is set to 1, the adst bit is cleared to 0, and the a/d converter becomes idle. 3. since adf = 1 and adie = 1, an adi interrupt is requested. 4. the a/d interrupt handling routine starts. 5. the routine reads adcsr, then writes 0 to the adf flag. 6. the routine reads and processes the conversion result (addrb). 7. execution of the a/d interrupt handling routine ends. after that, if the adst bit is set to 1, a/d conversion starts again and steps 2 to 7 are repeated.
641 adie adst adf state of channel 0 (an0) a/d conversion starts 2 1 addra addrb addrc addrd state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) note: * vertical arrows ( ) indicate instructions executed by software. set * set * clear * clear * a/d conversion result 1 a/d conversion a/d conversion result 2 read conversion result read conversion result idle idle idle idle idle idle a/d conversion set * figure 20.3 example of a/d converter operation (single mode, channel 1 selected)
642 20.4.2 scan mode (scan = 1) scan mode is useful for monitoring analog inputs in a group of one or more channels. when the adst bit is set to 1 by software, or by timer or external trigger input, a/d conversion starts on the first channel in the group (an0 when ch2 = 0; an4 when ch2 = 1). when two or more channels are selected, after conversion of the first channel ends, conversion of the second channel (an1 or an5) starts immediately. a/d conversion continues cyclically on the selected channels until the adst bit is cleared to 0. the conversion results are transferred for storage into the addr registers corresponding to the channels. when the operating mode or analog input channel must be changed during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1 to start a/d conversion again. the adst bit can be set at the same time as the operating mode or input channel is changed. typical operations when three channels (an0 to an2) are selected in scan mode are described next. figure 20.4 shows a timing diagram for this example. 1. scan mode is selected (scan = 1), scan group 0 is selected (ch2 = 0), analog input channels an0 to an2 are selected (ch1 = 1, ch0 = 0), and a/d conversion is started (adst = 1) 2. when a/d conversion of the first channel (an0) is completed, the result is transferred to addra. next, conversion of the second channel (an1) starts automatically. 3. conversion proceeds in the same way through the third channel (an2). 4. when conversion of all the selected channels (an0 to an2) is completed, the adf flag is set to 1 and conversion of the first channel (an0) starts again. if the adie bit is set to 1 at this time, an adi interrupt is requested after a/d conversion ends. 5. steps 2 to 4 are repeated as long as the adst bit remains set to 1. when the adst bit is cleared to 0, a/d conversion stops. after that, if the adst bit is set to 1, a/d conversion starts again from the first channel (an0).
643 adst adf addra addrb addrc addrd state of channel 0 (an0) state of channel 1 (an1) state of channel 2 (an2) state of channel 3 (an3) set * 1 clear * 1 idle notes: 1. vertical arrows ( ) indicate instructions executed by software. 2. data currently being converted is ignored. clear * 1 idle idle a/d conversion time idle continuous a/d conversion execution a/d conversion 1 idle idle idle idle idle transfer * 2 a/d conversion 3 a/d conversion 2 a/d conversion 5 a/d conversion 4 a/d conversion result 1 a/d conversion result 2 a/d conversion result 3 a/d conversion result 4 figure 20.4 example of a/d converter operation (scan mode, channels an0 to an2 selected)
644 20.4.3 input sampling and a/d conversion time the a/d converter has a built-in sample-and-hold circuit. the a/d converter samples the analog input at a time t d after the adst bit is set to 1, then starts conversion. figure 20.5 shows the a/d conversion timing. table 20.4 indicates the a/d conversion time. as indicated in figure 20.5, the a/d conversion time includes t d and the input sampling time. the length of t d varies depending on the timing of the write access to adcsr. the total conversion time therefore varies within the ranges indicated in table 20.4. in scan mode, the values given in table 20.4 apply to the first conversion time. in the second and subsequent conversions the conversion time is fixed at 256 states when cks = 0 or 128 states when cks = 1. (1) (2) t d t spl t conv input sampling timing adf address write signal legend: (1): adcsr write cycle (2): adcsr address t d : a/d conversion start delay t spl : input sampling time t conv : a/d conversion time figure 20.5 a/d conversion timing
645 table 20.4 a/d conversion time (single mode) cks = 0 cks = 1 item symbol min typ max min typ max a/d conversion start delay t d 10?76 ? input sampling time t spl ?331 a/d conversion time t conv 259 266 131 134 note: values in the table are the number of states. 20.4.4 external trigger input timing a/d conversion can be externally triggered. when the trgs1 and trgs0 bits are set to 11 in adcr, external trigger input is enabled at the adtrg pin. a falling edge at the adtrg pin sets the adst bit to 1 in adcsr, starting a/d conversion. other operations, in both single and scan modes, are the same as when the adst bit is set to 1 by software. figure 20.6 shows the timing. ? adtrg internal trigger signal adst a/d conversion figure 20.6 external trigger input timing 20.5 interrupts the a/d converter generates an interrupt (adi) at the end of a/d conversion. the adi interrupt request can be enabled or disabled by the adie bit in adcsr.
646 20.6 usage notes the following points should be noted when using the a/d converter. setting range of analog power supply and other pins: 1. analog input voltage range the voltage applied to the ann analog input pins during a/d conversion should be in the range avss ann avref (n = 0 to 7). 2. digital input voltage range the voltage applied to the cinn digital input pins should be in the range avss cinn avref and vss cinn vcc (n = 0 to 15). 3. relation between avcc, avss and vcc, vss as the relationship between avcc, avss and vcc, vss, set avss = vss. if the a/d converter is not used, the avcc and avss pins must on no account be left open. 4. setting range of avref pin: the reference voltage supplied via the avref pin should be in the range avref avcc. if conditions 1 to 4 above are not met, the reliability of the device may be adversely affected. notes on board design: in board design, digital circuitry and analog circuitry should be as mutually isolated as possible, and layout in which digital circuit signal lines and analog circuit signal lines cross or are in close proximity should be avoided as far as possible. failure to do so may result in incorrect operation of the analog circuitry due to inductance, adversely affecting a/d conversion values. also, digital circuitry must be isolated from the analog input signals (an0 to an7), analog reference power supply (avref), and analog power supply (avcc) by the analog ground (avss). also, the analog ground (avss) should be connected at one point to a stable digital ground (vss) on the board. notes on noise countermeasures: a protection circuit connected to prevent damage due to an abnormal voltage such as an excessive surge at the analog input pins (an0 to an7) or analog reference power supply pin (avref) should be connected between avcc and avss as shown in figure 20.7. also, the bypass capacitors connected to avcc, avref and the filter capacitor connected to an0 to an7 must be connected to avss. if a filter capacitor is connected as shown in figure 20.7, the input currents at the analog input pins (an0 to an7) are averaged, and so an error may arise. also, when a/d conversion is performed frequently, as in scan mode, if the current charged and discharged by the capacitance of the
647 sample-and-hold circuit in the a/d converter exceeds the current input via the input impedance (r in ), an error will arise in the analog input pin voltage. careful consideration is therefore required when deciding the circuit constants. avcc * 1 avref an0 to an7 avss notes: figures are reference values. 1. 2. r in : input impedance * 1 r in * 2 100 0.1 f 0.01 f 10 f figure 20.7 example of analog input protection circuit table 20.5 analog pin ratings item min max unit analog input capacitance 20 pf permissible signal source impedance 5 * k w note: * when v cc = 2.7 to 3.6 v and ? 10 mhz. an0 to an7 10 k w 20 pf to a/d converter note: numeric values are reference values. figure 20.8 analog input pin equivalent circuit
648 a/d conversion precision definitions: h8s/2169 or h8s/2149 a/d conversion precision definitions are given below. ? resolution the number of a/d converter digital output codes ? offset error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from the minimum voltage value b'0000000000 (h'000) to b'0000000001 (h'001) (see figure 20.10). ? full-scale error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from b'1111111110 (h'3fe) to b'1111111111 (h'3ff) (see figure 20.11). ? quantization error the deviation inherent in the a/d converter, given by 1/2 lsb (see figure 20.9). ? nonlinearity error the error with respect to the ideal a/d conversion characteristic between the zero voltage and the full-scale voltage. does not include the offset error, full-scale error, or quantization error. ? absolute precision the deviation between the digital value and the analog input value. includes the offset error, full-scale error, quantization error, and nonlinearity error.
649 h'3ff h'3fe h'3fd h'004 h'003 h'002 h'001 h'000 1 1024 2 1024 1023 1024 1022 1024 fs quantization error digital output ideal a/d conversion characteristic analog input voltage figure 20.9 a/d conversion precision definitions (1)
650 fs offset error nonlinearity error actual a/d conversion characteristic analog input voltage digital output ideal a/d conversion characteristic full-scale error figure 20.10 a/d conversion precision definitions (2)
651 permissible signal source impedance: h8s/2169 or h8s/2149 analog input is designed so that conversion precision is guaranteed for an input signal for which the signal source impedance is 5 k w or less. this specification is provided to enable the a/d converter? sample-and-hold circuit input capacitance to be charged within the sampling time; if the sensor output impedance exceeds 5 k w , charging may be insufficient and it may not be possible to guarantee the a/d conversion precision. however, if a large capacitance is provided externally, the input load will essentially comprise only the internal input resistance of 10 k w , and the signal source impedance is ignored. but since a low-pass filter effect is obtained in this case, it may not be possible to follow an analog signal with a large differential coefficient (e.g., 5 mv/ m sec or greater). when converting a high-speed analog signal, a low-impedance buffer should be inserted. influences on absolute precision: adding capacitance results in coupling with gnd, and therefore noise in gnd may adversely affect absolute precision. be sure to make the connection to an electrically stable gnd such as avss. care is also required to insure that filter circuits do not communicate with digital signals on the mounting board, so acting as antennas. a/d converter equivalent circuit the chip 20 pf c in = 15 pf 10 k low-pass filter c to 0.1 f sensor output impedance, up to 5 k w sensor input figure 20.11 example of analog input circuit
652
653 section 21 ram 21.1 overview the h8s/2169 or h8s/2149 has 2 kbytes of on-chip high-speed static ram. the on-chip ram is connected to the bus master by a 16-bit data bus, enabling both byte data and word data to be accessed in one state. this makes it possible to perform fast word data transfer. the on-chip ram can be enabled or disabled by means of the ram enable bit (rame) in the system control register (syscr). 21.1.1 block diagram figure 21.1 shows a block diagram of the on-chip ram. internal data bus (upper 8 bits) internal data bus (lower 8 bits) h'ffe880 h'ffe882 h'ffe884 h'ffeffe h'ffe881 h'ffe883 h'ffe885 h'ffefff h'ffff00 h'ffff7e h'ffff01 h'ffff7f figure 21.1 block diagram of ram
654 21.1.2 register configuration the on-chip ram is controlled by syscr. table 21.1 shows the register configuration. table 21.1 register configuration name abbreviation r/w initial value address * system control register syscr r/w h'09 h'ffc4 note: * lower 16 bits of the address. 21.2 system control register (syscr) 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write the on-chip ram is enabled or disabled by the rame bit in syscr. for details of other bits in syscr, see section 3.2.2, system control register (syscr). bit 0?am enable (rame): enables or disables the on-chip ram. the rame bit is initialized when the reset state is released. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value)
655 21.3 operation 21.3.1 expanded mode (modes 1, 2, and 3 (expe = 1)) when the rame bit is set to 1, accesses to h8s/2169 or h8s/2149 addresses h'(ff)e880 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the on-chip ram. when the rame bit is cleared to 0, accesses to addresses h'(ff)e080 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the external address space. since the on-chip ram is connected to the bus master by a 16-bit data bus, it can be written to and read in byte or word units. each type of access is performed in one state. even addresses use the upper 8 bits, and odd addresses use the lower 8 bits. word data must start at an even address. 21.3.2 single-chip mode (modes 2 and 3 (expe = 0)) when the rame bit is set to 1, accesses to h8s/2169 or h8s/2149 addresses h'(ff)e880 to h'(ff)efff and h'(ff)ff00 to h'(ff)ff7f, are directed to the on-chip ram. when the rame bit is cleared to 0, the on-chip ram is not accessed. undefined values are always read from these bits, and writing is invalid. since the on-chip ram is connected to the bus master by a 16-bit data bus, it can be written to and read in byte or word units. each type of access is performed in one state. even addresses use the upper 8 bits, and odd addresses use the lower 8 bits. word data must start at an even address.
656
657 section 22 rom 22.1 overview the h8s/2169 or h8s/2149 has 64 kbytes of on-chip rom (flash memory). the rom is connected to the bus master by a 16-bit data bus. the bus master accesses both byte and word data in one state, enabling faster instruction fetches and higher processing speed. the mode pins (md1 and md0) and the expe bit in mdcr can be set to enable or disable the on-chip rom. the chip can be erased and programmed on-board as well as with a general-purpose prom programmer. 22.1.1 block diagram figure 22.1 shows a block diagram of the rom. h'000000 h'000002 h'00fffe h'000001 h'000003 h'00ffff internal data bus (upper 8 bits) internal data bus (lower 8 bits) figure 22.1 rom block diagram
658 22.1.2 register configuration the chip on-chip rom is controlled by the operating mode and register mdcr. the register configuration is shown in table 22.1. table 22.1 rom register register name abbreviation r/w initial value address * mode control register mdcr r/w undefined depends on the operating mode h'ffc5 note: * lower 16 bits of the address. 22.2 register descriptions 22.2.1 mode control register (mdcr) bit initial value read/write 7 expe * r/w * 6 0 5 0 4 0 3 0 0 mds0 * r 2 0 1 mds1 * r note: * determined by the md1 and md0 pins. mdcr is an 8-bit read-only register used to set the chip operating mode and monitor the current operating mode. the expe bit is initialized in accordance with the mode pin states by a reset and in hardware standby mode. bit 7?xpanded mode enable (expe): sets expanded mode. in mode 1, expe is fixed at 1 and cannot be modified. in modes 2 and 3, expe has an initial value of 0 and can be read or written. bit 7 expe description 0 single-chip mode selected 1 expanded mode selected
659 bits 6 to 2?reserved: these bits cannot be modified and are always read as 0. bits 1 and 0?ode select 1 and 0 (mds1, mds0): these bits indicate values that reflects the input levels of mode pins md1 and md0 (the current operating mode). bits mds1 and mds0 correspond to pins md1 and md0, respectively. these are read-only bits, and cannot be modified. when mdcr is read, the input levels of mode pins md1 and md0 are latched in these bits. 22.3 operation the on-chip rom is connected to the cpu by a 16-bit data bus, and both byte and word data is accessed in one state. even addresses are connected to the upper 8 bits, and odd addresses to the lower 8 bits. word data must start at an even address. the mode pins (md1 and md0) and the expe bit in mdcr can be set to enable or disable the on-chip rom, as shown in table 22.2. in normal mode, the maximum amount of rom that can be used is 56 kbytes. table 22.2 operating modes and rom operating mode mcu operating cpu operating mode pins mdcr mode mode description md1 md0 expe on-chip rom mode 1 normal expanded mode with on-chip rom disabled 0 1 1 disabled mode 2 advanced single-chip mode 1 0 0 enabled advanced expanded mode with on-chip rom enabled 1 (64 kbytes) mode 3 normal single-chip mode 1 0 enabled normal expanded mode with on-chip rom enabled 1 (56 kbytes)
660 22.4 overview of flash memory 22.4.1 features the features of the flash memory are summarized below. ? four flash memory operating modes ? program mode ? erase mode ? program-verify mode ? erase-verify mode ? programming/erase methods the flash memory is programmed 128 bytes at a time. erasing is performed by block erase (in single-block units). when erasing multiple blocks, the individual blocks must be erased sequentially. block erasing can be performed as required on 1-kbyte, 28-kbyte, 16-kbyte, and 8-kbyte blocks. ? programming/erase times the flash memory programming time is 10 ms (typ.) for simultaneous 128-byte programming, equivalent to about 80 m s (typ.) per byte, and the erase time is 100 ms (typ.) per block. ? reprogramming capability the flash memory can be reprogrammed up to 100 times. ? on-board programming modes there are two modes in which flash memory can be programmed/erased/verified on-board: ? boot mode ? user program mode ? automatic bit rate adjustment with data transfer in boot mode, the bit rate of the chip can be automatically adjusted to match the transfer bit rate of the host. ? protect modes there are three protect modes, hardware, software, and error protect, which allow protected status to be designated for flash memory program/erase/verify operations. ? programmer mode flash memory can be programmed/erased in programmer mode, using a prom programmer, as well as in on-board programming mode.
661 22.4.2 block diagram module bus bus interface/controller flash memory (64 kbytes) operating mode flmcr2 internal address bus internal data bus (16 bits) mode pins ebr1 ebr2 flmcr1 legend: flmcr1: flash memory control register 1 flmcr2: flash memory control register 2 ebr1: erase block register 1 ebr2: erase block register 2 figure 22.2 block diagram of flash memory
662 22.4.3 flash memory operating modes mode transitions: when the mode pins are set in the reset state and a reset-start is executed, the mcu enters one of the operating modes shown in figure 22.3. in user mode, flash memory can be read but not programmed or erased. flash memory can be programmed and erased in boot mode, user program mode, and programmer mode. boot mode on-board programming mode user program mode user mode with on-chip rom enabled reset state programmer mode res = 0 swe = 1 swe = 0 * 1 * 2 notes: only make a transition between user mode and user program mode when the cpu is not accessing the flash memory. 1. md0 = md1 = 0, p92 = p91 = p90 = 1 2. md0 = md1 = 0, p92 = 0, p91 = p90 = 1 res = 0 res = 0 res = 0 md1 = 1 figure 22.3 flash memory mode transitions
663 on-board programming modes boot mode flash memory the chip ram host programming control program sci application program (old version)      programming control program new application program new application program flash memory the chip ram host sci application program (old version) boot program area programming control program new application program flash memory the chip ram host sci flash memory erase boot program flash memory the chip program execution state ram host sci new application program boot program   
 " #      ! " 1. initial state the flash memory is in the erased state when the device is shipped. the description here applies to the case where the old program version or data is being rewritten. the user should prepare the programming control program and new application program beforehand in the host. 2. programming control program transfer when boot mode is entered, the boot program in the chip (originally incorporated in the chip) is started, an sci communication check is carried out, and the boot program required for flash memory erasing is automatically transferred to the ram boot program area. 3. flash memory initialization the erase program in the boot program area (in ram) is executed, and the flash memory is initialized (to h'ff). in boot mode, entire flash memory erasure is performed, without regard to blocks. 4. writing new application program the programming control program transferred from the host to ram by sci communication is executed, and the new application program in the host is written into the flash memory. boot program boot program boot program area programming control program boot program area     programming control program figure 22.4 boot mode
664 user program mode flash memory the chip ram host programming/ erase control program sci boot program new application program flash memory the chip ram host sci new application program flash memory the chip ram host sci flash memory erase boot program new application program flash memory the chip program execution state ram host sci boot program      !  boot program application program (old version)     new application program       1. initial state (1) the program that will transfer the programming/ erase control program to on-chip ram should be written into the flash memory by the user beforehand. (2) the programming/erase control program should be prepared in the host or in the flash memory. 2. programming/erase control program transfer the transfer program in the flash memory is executed, and the programming/erase control program is transferred to ram. 3. flash memory initialization the programming/erase program in ram is executed, and the flash memory is initialized (to h'ff). erasing can be performed in block units, but not in byte units. 4. writing new application program next, the new application program in the host is written into the erased flash memory blocks. do not write to unerased blocks. programming/ erase control program programming/ erase control program programming/ erase control program transfer program application program (old version) transfer program transfer program transfer program figure 22.5 user program mode (example)
665 differences between boot mode and user program mode table 22.3 differences between boot mode and user program mode boot mode user program mode entire memory erase yes yes block erase no yes programming control program * program/program-verify program/program-verify erase/erase-verify note: to be provided by the user, in accordance with the recommended algorithm. block configuration: the flash memory is divided into two 8-kbyte blocks, one 16-kbyte block, one 28-kbyte block, and four 1-kbyte blocks. address h'00000 address h'0ffff 1 kbyte 1 kbyte 1 kbyte 1 kbyte 8 kbytes 8 kbytes 16 kbytes 28 kbytes 64 kbytes figure 22.6 flash memory block configuration
666 22.4.4 pin configuration the flash memory is controlled by means of the pins shown in table 22.4. table 22.4 flash memory pins pin name abbreviation i/o function reset res input reset mode 1 md1 input sets mcu operating mode mode 0 md0 input sets mcu operating mode port 92 p92 input sets mcu operating mode when md1=md0 = 0 port 91 p91 input sets mcu operating mode when md1 = md0 = 0 port 90 p90 input sets mcu operating mode when md1 = md0 = 0 transmit data txd1 output serial transmit data output receive data rxd1 input serial receive data input 22.4.5 register configuration the registers used to control the on-chip flash memory when enabled are shown in table 22.5. in order for these registers to be accessed, the flshe bit must be set to 1 in stcr. table 22.5 flash memory registers register name abbreviation r/w initial value address * 1 flash memory control register 1 flmcr1 * 5 r/w * 3 h'80 h'ff80 * 2 flash memory control register 2 flmcr2 * 5 r/w * 3 h'00 * 4 h'ff81 * 2 erase block register 1 ebr1 * 5 * 3 h'00 * 4 h'ff82 * 2 erase block register 2 ebr2 * 5 r/w * 3 h'00 * 4 h'ff83 * 2 serial/timer control register stcr r/w h'00 h'ffc3 notes: 1. lower 16 bits of the address. 2. flash memory registers share addresses with other registers. register selection is performed by the flshe bit in the serial/timer control register (stcr). 3. in modes in which the on-chip flash memory is disabled, a read will return h'00, and writes are invalid. 4. when the swe bit in flmcr1 is not set, these registers are initialized to h'00. 5. flmcr1, flmcr2, ebr1, and ebr2 are 8-bit registers. only byte accesses are valid for these registers, the access requiring 2 states.
667 22.5 register descriptions 22.5.1 flash memory control register 1 (flmcr1) bit 76543210 fwe swe ? ? ev pv e p initial value 1 0 0 0 0 0 0 0 read/write r r/w ? ? r/w r/w r/w r/w flmcr1 is an 8-bit register used for flash memory operating mode control. program-verify mode or erase-verify mode is entered by setting swe to 1. program mode is entered by setting swe to 1, then setting the psu bit in flmcr2, and finally setting the p bit. erase mode is entered by setting swe to 1, then setting the esu bit in flmcr2, and finally setting the e bit. flmcr1 is initialized to h'80 by a reset, and in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode. when on-chip flash memory is disabled, a read will return h'00, and writes are invalid. writes to the ev and pv bits in flmcr1 are enabled only when swe=1; writes to the e bit only when swe = 1, and esu = 1; and writes to the p bit only when swe = 1, and psu = 1. bit 7?lash write enable (fwe): sets hardware protection against flash memory programming/erasing. this bit cannot be modified and is always read as 1. bit 6?oftware write enable (swe): enables or disables flash memory programming. swe should be set before setting bits esu, psu, ev, pv, e, p, and eb7 to eb0, and should not be cleared at the same time as these bits. bit 6 swe description 0 writes disabled (initial value) 1 writes enabled bit 5 and 4?eserved: these bits cannot be modified and are always read as 0. bit 3?rase-verify (ev): selects erase-verify mode transition or clearing. do not set the swe, esu, psu, pv, e, or p bit at the same time.
668 bit 3 ev description 0 erase-verify mode cleared (initial value) 1 transition to erase-verify mode [setting condition] when swe = 1 bit 2?program-verify (pv): selects program-verify mode transition or clearing. do not set the swe, esu, psu, ev, e, or p bit at the same time. bit 2 pv description 0 program-verify mode cleared (initial value) 1 transition to program-verify mode [setting condition] when swe = 1 bit 1?rase (e): selects erase mode transition or clearing. do not set the swe, esu, psu, ev, pv, or p bit at the same time. bit 1 e description 0 erase mode cleared (initial value) 1 transition to erase mode [setting condition] when swe = 1, and esu = 1 bit 0?rogram (p): selects program mode transition or clearing. do not set the swe, psu, esu, ev, pv, or e bit at the same time. bit 0 p description 0 program mode cleared (initial value) 1 transition to program mode [setting condition] when swe = 1, and psu = 1
669 22.5.2 flash memory control register 2 (flmcr2) bit 76543210 fler ? ? ? ? ? esu psu initial value 0 0 0 0 0 0 0 0 read/write r ? ? ? ? ? r/w r/w flmcr2 is an 8-bit register that monitors the presence or absence of flash memory program/erase protection (error protection) and performs setup for flash memory program/erase mode. flmcr2 is initialized to h'00 by a reset, and in hardware standby mode. the esu and psu bits are cleared to 0 in software standby mode, subactive mode, subsleep mode, and watch mode. when on-chip flash memory is disabled, a read will return h'00 and writes are invalid. bit 7?lash memory error (fler): indicates that an error has occurred during an operation on flash memory (programming or erasing). when fler is set to 1, flash memory goes to the error- protection state. bit 7 fler description 0 flash memory is operating normally flash memory program/erase protection (error protection) is disabled [clearing condition] reset or hardware standby mode (initial value) 1 an error has occurred during flash memory programming/erasing flash memory program/erase protection (error protection) is enabled [setting condition] see section 22.8.3, error protection bits 6 to 2?eserved: should always be written with 0. bit 1?rase setup (esu): prepares for a transition to erase mode. set this bit to 1 before setting the e bit to 1 in flmcr1. do not set the swe, psu, ev, pv, e, or p bit at the same time.
670 bit 1 esu description 0 erase setup cleared (initial value) 1 erase setup [setting condition] when swe = 1 bit 0?program setup (psu): prepares for a transition to program mode. set this bit to 1 before setting the p bit to 1 in flmcr1. do not set the swe, esu, ev, pv, e, or p bit at the same time. bit 0 psu description 0 program setup cleared (initial value) 1 program setup [setting condition] when swe = 1 22.5.3 erase block registers 1 and 2 (ebr1, ebr2) bit 76543210 ebr1 initial value 0 0 0 0 0 0 0 0 read/write * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 bit 76543210 ebr2 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 initial value 0 0 0 0 0 0 0 0 read/write r/w * 1 r/w r/w r/w r/w r/w r/w r/w notes: 1. in normal mode, these bits cannot be modified and are always read as 0. 2. this bit must not be set to 1. ebr1 and ebr2 are registers that specify the flash memory erase area block by block; bits 7 to 0 in ebr2 are readable/writable bits. ebr1 and ebr2 are each initialized to h'00 by a reset, in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode, and when the swe bit in flmcr1 is not set. when a bit in ebr2 is set, the corresponding block can be erased. other blocks are erase-protected. set only one bit in ebr2 (more than one bit cannot be set). when on-chip flash memory is disabled, a read will return h'00, and writes are invalid.
671 the flash memory block configuration is shown in table 22.6. table 22.6 flash memory erase blocks block (size) address eb0 (1 kbyte) h'(00)0000 to h'(00)03ff eb1 (1 kbyte) h'(00)0400 to h'(00)07ff eb2 (1 kbyte) h'(00)0800 to h'(00)0bff eb3 (1 kbytes) h'(00)0c00 to h'(00)0fff eb4 (28 kbytes) h'(00)1000 to h'(00)7fff eb5 (16 kbytes) h'(00)8000 to h'(00)bfff eb6 (8 kbytes) h'(00)c000 to h'(00)dfff eb7 (8 kbytes) h'00e000 to h'00ffff 22.5.4 serial/timer control register (stcr) bit 76543210 iics iicx1 iicx0 iice flshe icks1 icks0 initial value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w stcr is an 8-bit readable/writable register that controls register access, the iic operating mode (when the on-chip iic option is included), and on-chip flash memory, and also selects the tcnt input clock. for details on functions not related to on-chip flash memory, see section 3.2.4, serial/timer control register (stcr), and descriptions of individual modules. if a module controlled by stcr is not used, do not write 1 to the corresponding bit. stcr is initialized to h'00 by a reset and in hardware standby mode. bits 7 to 4? 2 c control (iics, iicx1, iicx0, iice): these bits control the operation of the i 2 c bus interface. for details, see section 16, i 2 c bus interface.
672 bit 3?flash memory control register enable (flshe): setting the flshe bit to 1 enables read/write access to the flash memory control registers. if flshe is cleared to 0, the flash memory control registers are deselected. in this case, the flash memory control register contents are retained. bit 3 flshe description 0 flash memory control registers deselected (initial value) 1 flash memory control registers selected bit 2?eserved: do not write 1 to this bit. bits 1 and 0?nternal clock select 1 and 0 (icks1, icks0): these bits control 8-bit timer operation. see section 12, 8-bit timers, for details. 22.6 on-board programming modes when pins are set to on-board programming mode, program/erase/verify operations can be performed on the on-chip flash memory. there are two on-board programming modes: boot mode and user program mode. the pin settings for transition to each of these modes are shown in table 22.7. for a diagram of the transitions to the various flash memory modes, see figure 22.3. only advanced mode setting is possible for boot mode. in the case of user program mode, established in advanced mode or normal mode, depending on the setting of the md0 pin. in normal mode, only programming of a 56-kbyte area of flash memory is possible. table 22.7 setting on-board programming modes mode mode name cpu operating mode md1 md0 p92 p91 p90 boot mode advanced mode 0 0 1 * 1 * 1 * user program mode advanced mode 1 0 normal mode 1 note: * can be used as i/o ports after boot mode is initiated.
673 22.6.1 boot mode when boot mode is used, the flash memory programming control program must be prepared in the host beforehand. the channel 1 sci to be used is set to asynchronous mode. when a reset-start is executed after the chip? pins have been set to boot mode, the boot program built into the chip is started and the programming control program prepared in the host is serially transmitted to the chip via the sci. in the chip, the programming control program received via the sci is written into the programming control program area in on-chip ram. after the transfer is completed, control branches to the start address of the programming control program area and the programming control program execution state is entered (flash memory programming is performed). the transferred programming control program must therefore include coding that follows the programming algorithm given later. the system configuration in boot mode is shown in figure 22.7, and the boot program mode execution procedure in figure 22.8. rxd1 txd1 sci1 the chip flash memory write data reception verify data transmission host on-chip ram figure 22.7 system configuration in boot mode
674 n = n? yes no yes no set pins to boot mode and execute reset-start n = 1 n + 1 ? n host transfers data (h'00) continuously at prescribed bit rate the chip measures low period of h'00 data transmitted by host after bit rate adjustment, transmits one h'00 data byte to host to indicate end of adjustment host confirms normal reception of bit rate adjustment end indication (h'00), and transmits one h'55 data byte after receiving h'55, trransmit one h'aa data byte to host host transmits number of user program bytes (n), upper byte followed by lower byte the chip transmits received number of bytes to host as verify data (echo-back) host transmits programming control program sequentially in byte units the chip transmits received programming control program to host as verify data (echo-back) transfer received programming control program to on-chip ram end of transmission transmit one h'aa byte to host check flash memory data, and if data has already been written, erase all blocks confirm that all flash memory data has been erased check id code at beginning of user program transfer area execute programming control program transferred to on-chip ram start the chip calculates bit rate and sets value in bit rate register note: if a memory cell does not operate normally and cannot be erased, one h'ff byte is transmitted as an erase error, and the erase operation and subsequent operations are halted. id code match? transfer 1-byte of h'ff data as an id code error indicator and halt other operations. figure 22.8 boot mode execution procedure
675 automatic sci bit rate adjustment start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 low period (9 bits) measured (h'00 data) high period ( 1 or more bits ) figure 22.9 automatic sci bit rate adjustment when boot mode is initiated, the chip measures the low period of the asynchronous sci communication data (h'00) transmitted continuously from the host. the sci transmit/receive format should be set as follows: 8-bit data, 1 stop bit, no parity. the chip calculates the bit rate of the transmission from the host from the measured low period, and transmits one h'00 byte to the host to indicate the end of bit rate adjustment. the host should confirm that this adjustment end indication (h'00) has been received normally, and transmit one h'55 byte to the chip. if reception cannot be performed normally, initiate boot mode again (reset), and repeat the above operations. depending on the host? transmission bit rate and the chip? system clock frequency, there will be a discrepancy between the bit rates of the host and the chip. to ensure correct sci operation, the host? transfer bit rate should be set to (4800, 9600, or 19200) bps. table 22.8 shows typical host transfer bit rates and system clock frequencies for which automatic adjustment of the chip? bit rate is possible. the boot program should be executed within this system clock range. table 22.8 system clock frequencies for which automatic adjustment of the chip? bit rate is possible host bit rate system clock frequency for which automatic adjustment of the chip? bit rate is possible 19200 bps 8 mhz to 10 mhz 9600 bps 4 mhz to 10 mhz 4800 bps 2 mhz to 10 mhz on-chip ram area divisions in boot mode: in boot mode, the 1920-byte area from h'(ff)e880 to h'(ff) efff and the 128-byte area from h'(ff)ff00 to h'(ff)ff7f is reserved for use by the boot program, as shown in figure 22.10. the area to which the programming control program is transferred is h'(ff)e080 to h'(ff)e87f (2048 bytes). however, the 8-byte area from h'(ff)e080 to h'(ff)e087 is reserved for id codes as shown in figure 22.10. the boot program area can be used when the programming control program transferred into the reserved area enters the execution state. a stack area should be set up as required.
676 h'(ff)e080 h'(ff)efff h'(ff)e880 programming control program area * 1 (2040 bytes) id code area h'(ff)ff00 h'(ff)ff7f boot program area * 2 (128 bytes) boot program area * 2 (1920 bytes) h'(ff)e088 note: * 1 this reserved area is used only for boot mode operation. do not use this area for other purpose. * 2 the boot program area cannot be used until a transition is made to the execution state for the programming control program transferred to the reserved area. note that the boot program remains stored in this area after a branch is made to the programming control program. figure 22.10 ram areas in boot mode in boot mode in the chip, the contents of the 8-byte id code area shown below are checked to determine whether the program is a programming control program compatible with the chip. h'(ff)e080 40 fe 64 66 32 31 34 39 (product id code) h'(ff)e088 ~ programming control program instruction codes if an original programming control program is used in boot mode, the 8-byte id code shown above should be added at the beginning of the program. notes on use of boot mode: ? when the chip comes out of reset in boot mode, it measures the low period of the input at the sci? rxd1 pin. the reset should end with rxd1 high. after the reset ends, it takes about 100 states for the chip to get ready to measure the low period of the rxd1 input.
677 in boot mode, if any data has been programmed into the flash memory (if all data is not 1), all flash memory blocks are erased. boot mode is for use when user program mode is unavailable, such as the first time on-board programming is performed, or if the program activated in user program mode is accidentally erased. ? interrupts cannot be used while the flash memory is being programmed or erased. ? the rxd1 and txd1 pins should be pulled up on the board. ? before branching to the programming control program (ram area h'(ff)e088), the chip terminates transmit and receive operations by the on-chip sci (channel 1) (by clearing the re and te bits in scr to 0), but the adjusted bit rate value remains set in brr. the transmit data output pin, txd1, goes to the high-level output state (p84ddr = 1, p84dr = 1). the contents of the cpu? internal general registers are undefined at this time, so these registers must be initialized immediately after branching to the programming control program. in particular, since the stack pointer (sp) is used implicitly in subroutine calls, etc., a stack area must be specified for use by the programming control program. the initial values of other on-chip registers are not changed. ? boot mode can be entered by making the pin settings shown in table 22.7 and executing a reset-start. when the chip detects the boot mode setting at reset release* 1 , p92, p91, and p90 can be used as i/o ports. boot mode can be cleared by driving the reset pin low, waiting at least 20 states, then setting the mode pins, and executing reset release* 1 . boot mode can also be cleared by a wdt overflow reset. the mode pin input levels must not be changed in boot mode. ? if the mode pin input levels are changed (for example, from low to high) during a reset, the state of ports with multiplexed address functions and bus control output pins ( as , rd , hwr ) will change according to the change in the microcomputer? operating mode* 2 . therefore, care must be taken to make pin settings to prevent these pins from becoming output signal pins during a reset, or to prevent collision with signals outside the microcomputer. notes: 1. mode pins input must satisfy the mode programming setup time (t mds = 4 states) with respect to the reset release timing. 2. ports with multiplexed address functions will output a low level as the address signal if mode pin setting is for mode 1 is entered during a reset. in other modes, the port pins go to the high-impedance state. the bus control output signals will output a high level if mode pin setting is for mode 1 is entered during a reset. in other modes, the port pins go to the high-impedance state.
678 22.6.2 user program mode when set to user program mode, the chip can program and erase its flash memory by executing a user program/erase control program. therefore, on-board reprogramming of the on-chip flash memory can be carried out by providing an on-board means of supplying programming data, and storing a program/erase control program in part of the program area as necessary. to select user program mode, select a mode that enables the on-chip flash memory (mode 2 or 3). in this mode, on-chip supporting modules other than flash memory operate as they normally would in mode 2 and 3. the flash memory itself cannot be read while the swe bit is set to 1 to perform programming or erasing, so the control program that performs programming and erasing should be run in on-chip ram or external memory. figure 22.11 shows the procedure for executing the program/erase control program when transferred to on-chip ram. branch to flash memory application program branch to program/erase control program in ram area execute program/erase control program (flash memory rewriting) transfer program/erase control program to ram md1, md0 = 10, 11 reset-start write the transfer program (and the program/erase control program if necessary) beforehand note: the watchdog timer should be activated to prevent overprogramming or overerasing due to program runaway, etc. figure 22.11 user program mode execution procedure
679 22.7 programming/erasing flash memory in the on-board programming modes, flash memory programming and erasing is performed by software, using the cpu. there are four flash memory operating modes: program mode, erase mode, program-verify mode, and erase-verify mode. transitions to these modes can be made by setting the psu and esu bits in flmcr2, and the p, e, pv, and ev bits in flmcr1. the flash memory cannot be read while being programmed or erased. therefore, the program that controls flash memory programming/erasing (the programming control program) should be located and executed in on-chip ram or external memory. notes: 1. operation is not guaranteed if setting/resetting of the swe, ev, pv, e, and p bits in flmcr1, and the esu and psu bits in flmcr2, is executed by a program in flash memory. 2. perform programming in the erased state. do not perform additional programming on previously programmed addresses. 22.7.1 program mode follow the procedure shown in the program/program-verify flowchart in figure 22.12 to write data or programs to flash memory. performing program operations according to this flowchart will enable data or programs to be written to flash memory without subjecting the device to voltage stress or sacrificing program data reliability. programming should be carried out 128 bytes at a time. the wait times (x, y, z1, z2, z3, a , ? g, e, h, q) after setting/clearing individual bits in flash memory control registers 1 and 2 (flmcr1, flmcr2) and the maximum number of writes (n) are shown in section 25, electrical characteristics, flash memory characteristics. following the elapse of (x) m s or more after the swe bit is set to 1 in flash memory control register 1 (flmcr1), 128-byte program data is stored in the program data area and reprogram data area, and the 128-byte data in the reprogram data area written consecutively to the write addresses. the lower 8 bits of the first address written to must be h'00 or h'80. 128 consecutive byte data transfers are performed. the program address and program data are latched in the flash memory. a 128-byte data transfer must be performed even if writing fewer than 128 bytes; in this case, h'ff data must be written to the extra addresses. next, the watchdog timer is set to prevent overprogramming in the event of program runaway, etc. set a value greater than (y + z2 + a + b ) m s as the wdt overflow period. after this, preparation for program mode (program setup) is carried out by setting the psu bit in flmcr2, and after the elapse of (y) m s or more, the operating mode is switched to program mode by setting the p bit in flmcr1. the time during which the p bit is set is the flash memory programming time. make a program setting so that the time for one programming operation is within the range of (z1), (z2) or (z3) m s.
680 22.7.2 program-verify mode in program-verify mode, the data written in program mode is read to check whether it has been correctly written in the flash memory. after the elapse of a given programming time, the programming mode is exited (the p bit in flmcr1 is cleared, then the psu bit in flmcr2 is cleared at least ( a ) m s later). the watchdog timer is cleared after the elapse of ( b ) m s or more, and the operating mode is switched to program- verify mode by setting the pv bit in flmcr1. before reading in program-verify mode, a dummy write of h'ff data should be made to the addresses to be read. the dummy write should be executed after the elapse of ( g ) m s or more. when the flash memory is read in this state (verify data is read in 16-bit units), the data at the latched address is read. wait at least ( e ) m s after the dummy write before performing this read operation. next, the originally written data is compared with the verify data, and reprogram data is computed (see figure 22.12) and transferred to the reprogram data area. after 128 bytes of data have been verified, exit program-verify mode, wait for at least ( h ) m s. if the programming count is less than 6, the 128-byte data in the additional program data area should be written consecutively to the write addresses, and additional programming performed. next clear the swe bit in flmcr1, and wait at least ( q ) m s . if reprogramming is necessary, set program mode again, and repeat the program/program-verify sequence as before. however, ensure that the program/program-verify sequence is not repeated more than (n) times on the same bits.
681 start end of programming end sub set swe bit in flmcr1 wait (x) m s n = 1 m = 0 sub-routine-call see note 7 for pulse width note 7: write pulse width start of programming sub-routine write pulse set psu bit in flmcr2 enable wdt set p bit in flmcr1 wait (y) m s clear p bit in flmcr1 wait (z1) m s, (z2) m s or (z3) m s clear psu bit in flmcr2 wait ( a ) m s disable wdt wait ( b ) m s write pulse application subroutine ng ng ng ng ok ok wait ( g ) m s wait ( e ) m s * 2 * 4 * 5 * 1 wait ( h ) m s set pv bit in flmcr1 h'ff dummy write to verify address read verify data program data = verify data? transfer additional program data to additional program data area additional program data computation clear pv bit in flmcr1 clear swe bit in flmcr1 m = 1 end of 128-byte data verification? m = 0? increment address programming failure ok original data (d) 0 1 verify data (v) 0 1 0 1 comments write 128-byte data in ram reprogram data area consecutively to flash memory write pulse (z1) m s or (z2) m s ram program data storage area (128 bytes) reprogram data storage area (128 bytes) store 128-byte program data in program data area and reprogram data area number of writes n 1 2 3 4 5 6 7 8 9 10 11 12 13 . . . 998 999 1000 write time (z) m s z1 z1 z1 z1 z1 z1 z2 z2 z2 z2 z2 z2 z2 . . . z2 z2 z2 reprogram data computation transfer reprogram data to reprogram data area * 4 * 3 6 3 n? ng ok write 128-byte data in additional program data area in ram consecutively to flash memory additional write pulse (z3) m s wait ( q ) m s * 1 note: use a (z3) m s write pulse for additional programming. program data computation chart additional program data storage area (128 bytes) ok ok ng perform programming in the erased state. do not perform additional programming on previously programmed addresses. * 4 n ? n + 1 n 3 1000? clear swe bit in flmcr1 wait ( q ) m s 6 3 n? notes: 1. data transfer is performed by byte transfer. the lower 8 bits of the first address written to must be h'00 or h'80. a 1 28-byte data transfer must be performed even if writing fewer than 128 bytes; in this case, h'ff data must be written to the extra addresses. 2. verify data is read in 16-bit (word) units. 3. even bits for which programming has been completed in the 128-byte programming loop will be subjected to additional programmi ng if they fail the subsequent verify operation. 4. a 128-byte area for storing program data, a 128-byte area for storing reprogram data, and a 128-byte area for storing additio nal program data must be provided in ram. the reprogram and additional program data contents are modified as programming proceeds. 5. the write pulse of (z1) m s or (z2) m s is applied according to the progress of the programming operation. see note 7 for the pulse widths. when writing of additiona l program data is executed, a (z3) s write pulse should be applied. reprogram data x' means reprogram data when the write pulse is applied. 6. see section 25, electrical characteristics, flash memory characteristics, for the values of x, y, z1, z2, z3, a , b , g , e , h , q , and n. programming completed programming incomplete; reprogram still in erased state; no action reprogram data (x') 0 1 verify data (v) 0 1 0 1 additional program data (y) 0 1 1 1 comments additional program data computation chart additional programming executed additional programming not executed additional programming not executed reprogram data (x) 1 0 1 1 figure 22.12 program/program-verify flowchart
682 22.7.3 erase mode flash memory erasing should be performed block by block following the procedure shown in the erase/erase-verify flowchart (single-block erase) shown in figure 22.13. the wait times (x, y, z, a , b , g , e , h , q ) after setting/clearing individual bits in flash memory control registers 1 and 2 (flmcr1, flmcr2) and the maximum number of erase (n) are shown in section 25, electrical characteristics, flash memory characteristics. to perform data or program erasure, make a 1 bit setting for the flash memory area to be erased in erase block register 1 or 2 (ebr1 or ebr2) at least (x) m s after setting the swe bit to 1 in flash memory control register 1 (flmcr1). next, the watchdog timer is set to prevent overerasing in the event of program runaway, etc. set a value greater than (y + z + a + b ) ms as the wdt overflow period. after this, preparation for erase mode (erase setup) is carried out by setting the esu bit in flmcr2, and after the elapse of (y) m s or more, the operating mode is switched to erase mode by setting the e bit in flmcr1. the time during which the e bit is set is the flash memory erase time. ensure that the erase time does not exceed (z) ms. note: with flash memory erasing, preprogramming (setting all data in the memory to be erased to 0) is not necessary before starting the erase procedure. 22.7.4 erase-verify mode in erase-verify mode, data is read after memory has been erased to check whether it has been correctly erased. after the elapse of the erase time, erase mode is exited (the e bit in flmcr1 is cleared, then the esu bit in flmcr2 is cleared at least ( a ) m s later), the watchdog timer is cleared after the elapse of ( b ) m s or more, and the operating mode is switched to erase-verify mode by setting the ev bit in flmcr1. before reading in erase-verify mode, a dummy write of h'ff data should be made to the addresses to be read. the dummy write should be executed after the elapse of ( g ) m s or more. when the flash memory is read in this state (verify data is read in 16-bit units), the data at the latched address is read. wait at least ( e ) m s after the dummy write before performing this read operation. if the read data has been erased (all 1), a dummy write is performed to the next address, and erase-verify is performed. if the read data has not been erased, set erase mode again, and repeat the erase/erase-verify sequence in the same way. however, ensure that the erase/erase- verify sequence is not repeated more than (n) times. when verification is completed, exit erase- verify mode, and wait for at least ( h ) m s. if erasure has been completed on all the erase blocks, clear the swe bit in flmcr1, and wait ( q ) m s. if there are any unerased blocks, make a 1 bit setting in ebr1 or ebr2 for the flash memory area to be erased, and repeat the erase/erase-verify sequence in the same way.
683 end of erasing start set swe bit in flmcr1 set esu bit in flmcr2 set e bit in flmcr1 wait (x) m s wait (y) m s n = 1 set ebr1, ebr2 enable wdt * 5 * 5 * 3 wait (z) ms * 5 wait ( a ) m s * 5 wait ( b ) m s * 5 wait ( g ) m s set block start address to verify address * 5 wait ( e ) m s * 5 * 2 * 5 wait ( h ) m s * 5 * 5 * 4 start of erase clear e bit in flmcr1 clear esu bit in flmcr2 set ev bit in flmcr1 h'ff dummy write to verify address read verify data clear ev bit in flmcr1 wait ( h ) m s clear ev bit in flmcr1 clear swe bit in flmcr1 disable wdt halt erase * 1 verify data = all 1? last address of block? end of erasing of all erase blocks? erase failure clear swe bit in flmcr1 n 3 n? ng ng ng ng ok ok ok ok n ? n + 1 increment address wait ( q ) m s wait ( q ) m s notes: 1. preprogramming (setting erase block data to all 0) is not necessary. 2. verify data is read in 16-bit (w) units. 3. set only one bit in ebr1or ebr2. more than one bit cannot be set. 4. erasing is performed in block units. to erase a number of blocks, the individual blocks must be erased sequentially. 5. see section 25, electrical characteristics, flash memory characteristics, for the values of x, y, z, a , b , g , e , h , q , and n. figure 22.13 erase/erase-verify flowchart (single-block erase)
684 22.8 flash memory protection there are three kinds of flash memory program/erase protection: hardware protection, software protection, and error protection. 22.8.1 hardware protection hardware protection refers to a state in which programming/erasing of flash memory is forcibly disabled or aborted. hardware protection is reset by settings in flash memory control registers 1 and 2 (flmcr1, flmcr2) and erase block registers 1 and 2 (ebr1, ebr2). (see table 22.9.) table 22.9 hardware protection functions item description program erase reset/standby protection ? in a reset (including a wdt overflow reset) and in hardware standby mode, software standby mode, subactive mode, subsleep mode, and watch mode, flmcr1, flmcr2, ebr1, and ebr2 are initialized, and the program/erase-protected state is entered. ? in a reset via the res pin, the reset state is not entered unless the res pin is held low until oscillation stabilizes after powering on. in the case of a reset during operation, hold the res pin low for the res pulse width specified in the ac characteristics section. yes yes 22.8.2 software protection software protection can be implemented by setting the swe bit in flmcr1 and erase block registers 1 and 2 (ebr1, ebr2). when software protection is in effect, setting the p or e bit in flash memory control register 1 (flmcr1) does not cause a transition to program mode or erase mode. (see table 22.10.)
685 table 22.10 software protection functions item description program erase swe bit protection clearing the swe bit to 0 in flmcr1 sets the program/erase-protected state for all blocks. (execute in on-chip ram or external memory.) yes yes block specification protection erase protection can be set for individual blocks by settings in erase block registers 1 and 2 (ebr1, ebr2). setting ebr1 and ebr2 to h'00 places all blocks in the erase-protected state. ? yes 22.8.3 error protection in error protection, an error is detected when mcu runaway occurs during flash memory programming/erasing, or operation is not performed in accordance with the program/erase algorithm, and the program/erase operation is aborted. aborting the program/erase operation prevents damage to the flash memory due to overprogramming or overerasing. if the mcu malfunctions during flash memory programming/erasing, the fler bit is set to 1 in flmcr2 and the error protection state is entered. the flmcr1, flmcr2, ebr1, and ebr2 settings are retained, but program mode or erase mode is aborted at the point at which the error occurred. program mode or erase mode cannot be re-entered by re-setting the p or e bit. however, pv and ev bit setting is enabled, and a transition can be made to verify mode. fler bit setting conditions are as follows: ? when flash memory is read during programming/erasing (including a vector read or instruction fetch) ? immediately after exception handling (excluding a reset) during programming/erasing ? when a sleep instruction (including software standby, sleep, subactive, subsleep and watch mode) is executed during programming/erasing ? when the bus is released during programming/erasing error protection is released only by a reset and in hardware standby mode. figure 22.14 shows the flash memory state transition diagram.
686 rd vf pr er fler = 0 error occurrence * 1 res = 0 or stby = 0 res = 0 or stby = 0 rd vf pr er fler = 0 normal operation mode program mode erase mode reset or hardware standby (hardware protection) rd vf * 4 pr er fler = 1 rd vf pr er fler = 1 error protection mode error protection mode (software standby, sleep, subsleep, and watch ) software standby, sleep, subsleep, and watch mode flmcr1, flmcr2 (except fler bit), ebr1, ebr2 initialization state * 3 flmcr1, flmcr2, ebr1, ebr2 initialization state software standby, sleep, subsleep, and watch mode release rd: memory read possible vf: verify-read possible pr: programming possible er: erasing possible rd : memory read not possible vf : verify-read not possible pr : programming not possible er : erasing not possible legend: res = 0 or stby = 0 error occurrence * 2 notes: 1. when an error occurs other than due to a sleep instruction, or when a sleep instruction is executed for a transition to subactive mode 2. when an error occurs due to a sleep instruction (except subactive mode) 3. except sleep mode 4. vf in subactive mode figure 22.14 flash memory state transitions 22.9 interrupt handling when programming/erasing flash memory all interrupts, including nmi input is disabled when flash memory is being programmed or erased (when the p or e bit is set in flmcr1), and while the boot program is executing in boot mode* 1 , to give priority to the program or erase operation. there are three reasons for this: 1. interrupt during programming or erasing might cause a violation of the programming or erasing algorithm, with the result that normal operation could not be assured. 2. in the interrupt exception handling sequence during programming or erasing, the vector would not be read correctly* 2 , possibly resulting in mcu runaway. 3. if interrupt occurred during boot program execution, it would not be possible to execute the normal boot mode sequence.
687 for these reasons, in on-board programming mode alone there are conditions for disabling interrupt, as an exception to the general rule. however, this provision does not guarantee normal erasing and programming or mcu operation. all interrupt requests, including nmi input, must therefore be disabled inside and outside the mcu when programming or erasing flash memory. interrupt is also disabled in the error-protection state while the p or e bit remains set in flmcr1. notes: 1. interrupt requests must be disabled inside and outside the mcu until the programming control program has completed programming. 2. the vector may not be read correctly in this case for the following two reasons: ? if flash memory is read while being programmed or erased (while the p or e bit is set in flmcr1), correct read data will not be obtained (undetermined values will be returned). ? if the interrupt entry in the vector table has not been programmed yet, interrupt exception handling will not be executed correctly. 22.10 flash memory programmer mode 22.10.1 programmer mode setting programs and data can be written and erased in programmer mode as well as in the on-board programming modes. in programmer mode, the on-chip rom can be freely programmed using a prom programmer that supports hitachi microcomputer device types with 64-kbyte on-chip flash memory*. for precautions concerning the use of programmer mode, see section 22.10.10, notes on memory programming and section 22.11, flash memory programming and erasing precausions. flash memory read mode, auto-program mode, auto-erase mode, and status read mode are supported with these device types. in auto-program mode, auto-erase mode, and status read mode, a status polling procedure is used, and in status read mode, detailed internal signals are output after execution of an auto-program or auto-erase operation. table 22.11 shows programmer mode pin settings. note: set the programming voltage of the prom programmer to 3.3 v before using the chip.
688 table 22.11 programmer mode pin settings pin names setting/external circuit connection mode pins: md1, md0 low-level input to md1, md0 stby pin high-level input (hardware standby mode not set) res pin power-on reset circuit xtal and extal pins oscillation circuit other setting pins: p97, p92, p91, p90, p67 low-level input to p92, p67, high-level input to p97, p91, p90 22.10.2 socket adapters and memory map in programmer mode, a socket adapter is mounted on the writer programmer to match the package concerned. socket adapters are available for each manufacturer supporting hitachi microcomputer device types with 64-kbyte on-chip flash memory. figure 22.15 shows the memory map in programmer mode. for pin names in programmer mode, see section 1.3.2, pin functions in each operating mode. h'000000 mcu mode programmer mode h'00000 h'1ffff h'00ffff h'0ffff on-chip rom area undefined value output the chip figure 22.15 memory map in programmer mode 22.10.3 programmer mode operation table 22.12 shows how the different operating modes are set when using programmer mode, and table 22.13 lists the commands used in programmer mode. details of each mode are given below. ? memory read mode memory read mode supports byte reads. ? auto-program mode auto-program mode supports programming of 128 bytes at a time. status polling is used to confirm the end of auto-programming.
689 auto-erase mode auto-erase mode supports automatic erasing of the entire flash memory. status polling is used to confirm the end of auto-erasing. ? status read mode status polling is used for auto-programming and auto-erasing, and normal termination can be confirmed by reading the fo6 signal. in status read mode, error information is output if an error occurs. table 22.12 settings for each operating mode in programmer mode pin names mode ce oe we fo0 to fo7 fa0 to fa17 read l l h data output ain output disable l h h hi-z x command write l h l data input ain * 2 chip disable * 1 h x x hi-z x notes: 1. chip disable is not a standby state; internally, it is an operation state. 2. ain indicates that there is also address input in auto-program mode. table 22.13 programmer mode commands number 1st cycle 2nd cycle command name of cycles mode address data mode address data memory read mode 1 + n write x h'00 read ra dout auto-program mode 129 write x h'40 write wa din auto-erase mode 2 write x h'20 write x h'20 status read mode 2 write x h'71 write x h'71 notes: 1. in auto-program mode. 129 cycles are required for command writing by a simultaneous 128-byte write. 2. in memory read mode, the number of cycles depends on the number of address write cycles (n).
690 22.10.4 memory read mode after the end of an auto-program, auto-erase, or status read operation, the command wait state is entered. to read memory contents, a transition must be made to memory read mode by means of a command write before the read is executed. ? command writes can be performed in memory read mode, just as in the command wait state. ? once memory read mode has been entered, consecutive reads can be performed. ? after power-on, memory read mode is entered. table 22.14 ac characteristics in memory read mode conditions: v cc = 3.3 v 0.3 v, v ss ? 0 v, t a = 25 c 5 c item symbol min max unit command write cycle t nxtc 20 m s ce hold time t ceh 0?ns ce setup time t ces 0?ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns we rise time t r ?30ns we fall time t f ?30ns ce fa17 to fa0 fo7 to fo0 data oe we command write t wep t ceh t dh t ds t f t r t nxtc note: data is latched on the rising edge of we . t ces memory read mode address stable data figure 22.16 memory read mode timing waveforms after command write
691 table 22.15 ac characteristics when entering another mode from memory read mode conditions: v cc = 3.3 v 0.3 v, v ss = 0 v, t a = 25 c 5 c item symbol min max unit command write cycle t nxtc 20 m s ce hold time t ceh 0?ns ce setup time t ces 0?ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns we rise time t r ?30ns we fall time t f ?30ns ce fa17 to fa0 fo7 to fo0 h'xx oe we other mode command write memory read mode t wep t ceh t dh t ds t nxtc t ces address stable data t f t r note: do not enable we and oe at the same time. figure 22.17 timing waveforms when entering another mode from memory read mode
692 table 22.16 ac characteristics in memory read mode conditions: v cc = 3.3 v 0.3 v, v ss = 0 v, t a = 25 c 5 c item symbol min max unit access time t acc ?0 m s ce output delay time t ce ? 150 ns oe output delay time t oe ? 150 ns output disable delay time t df ? 100 ns data output hold time t oh 5?ns ce fa17 to fa0 fo7 to fo0 vil vil vih oe we t acc t acc address stable address stable data data t oh t oh figure 22.18 timing waveforms for ce / oe enable state read ce fa17 to fa0 fo7 to fo0 vih oe we t ce t acc t oe t oh t oh t df t ce t acc t oe address stable address stable data data t df figure 22.19 timing waveforms for ce / oe clocked read
693 22.10.5 auto-program mode ac characteristics table 22.17 ac characteristics in auto-program mode conditions: v cc = 3.3 v 0.3 v, v ss ? 0 v, t a = 25 c 5 c item symbol min max unit command write cycle t nxtc 20 m s ce hold time t ceh 0?ns ce setup time t ces 0?ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns status polling start time t wsts 1?ms status polling access time t spa ? 150 ns address setup time t as 0?ns address hold time t ah 60 ? ns memory write time t write 1 3000 ms we rise time t r ?30ns we fall time t f ?30ns data ce fa17 to fa0 fo7 to fo0 fo6 fo7 oe we t nxtc t wsts t nxtc t ces t ds t dh t wep t as t ah t ceh address stable programming wait data transfer 1 byte to 128 bytes h'40 data fo0 to 5 = 0 t f t r t spa t write (1 to 3000 ms) programming normal end identification signal programming operation end identification signal figure 22.20 auto-program mode timing waveforms
694 notes on use of auto-program mode in auto-program mode, 128 bytes are programmed simultaneously. this should be carried out by executing 128 consecutive byte transfers. ? a 128-byte data transfer is necessary even when programming fewer than 128 bytes. in this case, h'ff data must be written to the extra addresses. ? the lower 8 bits of the transfer address must be h'00 or h'80. if a value other than an effective address is input, processing will switch to a memory write operation but a write error will be flagged. ? memory address transfer is performed in the second cycle (figure 22.20). do not perform transfer after the second cycle. ? do not perform a command write during a programming operation. ? perform one auto-programming operation for a 128-byte block for each address. characteristics are not guaranteed for two or more programming operations. ? confirm normal end of auto-programming by checking fo6. alternatively, status read mode can also be used for this purpose (fo7 status polling uses the auto-program operation end identification pin). ? the status polling fo6 and fo7 pin information is retained until the next command write. until the next command write is performed, reading is possible by enabling ce and oe . 22.10.6 auto-erase mode ac characteristics table 22.18 ac characteristics in auto-erase mode conditions: v cc = 3.3 v 0.3 v, v ss ???, t a = 25 c 5 c item symbol min max unit command write cycle t nxtc 20 m s ce hold time t ceh 0?ns ce setup time t ces 0?ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns status polling start time t ests 1?ms status polling access time t spa ? 150 ns memory erase time t erase 100 40000 ms we rise time t r ?30ns we fall time t f ?30ns
695 ce fa17 to fa0 fo7 to fo0 fo6 fo7 oe we t ests t nxtc t nxtc t ces t ceh t dh cl in dl in t wep fo0 to fo5 = 0 h'20 h'20 erase normal end confirmation signal t f t r t ds t spa t erase (100 to 40000 ms) erase end identification signal figure 22.21 auto-erase mode timing waveforms notes on use of auto-erase-program mode ? auto-erase mode supports only entire memory erasing. ? do not perform a command write during auto-erasing. ? confirm normal end of auto-erasing by checking fo6. alternatively, status read mode can also be used for this purpose (fo7 status polling uses the auto-erase operation end identification pin). ? the status polling fo6 and fo7 pin information is retained until the next command write. until the next command write is performed, reading is possible by enabling ce and oe .
696 22.10.7 status read mode status read mode is used to identify what type of abnormal end has occurred. use this mode when an abnormal end occurs in auto-program mode or auto-erase mode. ? the return code is retained until a command write for other than status read mode is performed. table 22.19 ac characteristics in status read mode conditions: v cc = 3.3 v 0.3 v, v ss ?? v, t a = 25 c 5 c item symbol min max unit command write cycle t nxtc 20 m s ce hold time t ceh 0?ns ce setup time t ces 0?ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns oe output delay time t oe ? 150 ns disable delay time t df ? 100 ns ce output delay time t ce ? 150 ns we rise time t r ?30ns we fall time t f ?30ns ce fa17 to fa0 fo7 to fo0 oe we t ces t nxtc t nxtc t df note: fo2 and fo3 are undefined. t ces t dh t wep t wep data t dh t oe t ce t nxtc h'71 t f t r t f t r t ceh t ds t ds h'71 t ceh figure 22.22 status read mode timing waveforms
697 table 22.20 status read mode return commands pin name fo7 fo6 fo5 fo4 fo3 fo2 fo1 fo0 attribute normal end identification command error program- ming error erase error ? ? program- ming or erase count exceeded effective address error initial value 00000000 indications normal end: 0 abnormal end: 1 command error: 1 otherwise: 0 program- ming error: 1 otherwise: 0 erase error: 1 otherwise: 0 ? ? count exceeded: 1 otherwise: 0 effective address error: 1 otherwise: 0 note: fo2 and fo3 are undefined. 22.10.8 status polling the fo7 status polling flag indicates the operating status in auto-program or auto-erase mode. ? the fo6 status polling flag indicates a normal or abnormal end in auto-program or auto-erase mode. table 22.21 status polling output truth table pin names internal operation in progress abnormal end normal end fo7 0 1 0 1 fo6 0 0 1 1 fo0 to fo5 0 0 0 0 22.10.9 programmer mode transition time commands cannot be accepted during the oscillation stabilization period or the programmer mode setup period. after the programmer mode setup time, a transition is made to memory read mode. table 22.22 command wait state transition time specifications item symbol min max unit standby release (oscillation stabilization time) t osc1 20?s programmer mode setup time t bmv 10?s v cc hold time t dwn 0ms
698 v cc res memory read mode command wait state command wait state normal/ abnormal end identification auto-program mode auto-erase mode t osc1 t bmv t dwn don't care command acceptance figure 22.23 oscillation stabilization time, programmer mode setup time, and power supply fall sequence 22.10.10 notes on memory programming ? when programming addresses which have previously been programmed, carry out auto- erasing before auto-programming. ? when performing programming using programmer mode on a chip that has been programmed/erased in an on-board programming mode, auto-erasing is recommended before carrying out auto-programming. notes: 1. the flash memory is initially in the erased state when the device is shipped by hitachi. for other chips for which the erasure history is unknown, it is recommended that auto- erasing be executed to check and supplement the initialization (erase) level. 2. auto-programming should be performed once only on the same address block. 22.11 flash memory programming and erasing precautions precautions concerning the use of on-board programming mode and programmer mode are summarized below. use the specified voltages and timing for programming and erasing: applied voltages in excess of the rating can permanently damage the device. use a prom programmer that supports 3.3 v programming voltage for hitachi microcomputer device types with 64-kbyte on-chip flash memory. do not select the hn28f101 setting for the prom programmer or 5.0 v setting for the programming voltage, and only use the specified socket adapter. incorrect use will result in damaging the device. powering on and off: when applying or disconnecting v cc , fix the res pin low and place the flash memory in the hardware protection state.
699 the power-on and power-off timing requirements should also be satisfied in the event of a power failure and subsequent recovery. use the recommended algorithm when programming and erasing flash memory: the recommended algorithm enables programming and erasing to be carried out without subjecting the device to voltage stress or sacrificing program data reliability. when setting the p or e bit in flmcr1, the watchdog timer should be set beforehand as a precaution against program runaway, etc. do not set or clear the swe bit during program execution in flash memory. wait for at least 100 m s after clearing the swe bit before executing a program or reading data in flash memory. when the swe bit is set, data in flash memory can be rewritten, but when swe = 1 the flash memory can only be read in program-verify or erase-verify mode. flash memory should only be accessed for verify operations (verification during programming/erasing). do not clear the swe bit during a program, erase, or verify operation. do not use interrupts while flash memory is being programmed or erased: all interrupt requests, including nmi, should be disabled when programming and erasing flash memory to give priority to program/erase operations. do not perform additional programming. erase the memory before reprogramming. in on- board programming, perform only one programming operation on a 128-byte programming unit block. in writer mode, too, perform only one programming operation on a 128-byte programming unit block. programming should be carried out with the entire programming unit block erased. before programming, check that the chip is correctly mounted in the prom programmer. overcurrent damage to the device can result if the index marks on the prom programmer socket, socket adapter, and chip are not correctly aligned. do not touch the socket adapter or chip during programming. touching either of these can cause contact faults and write errors.
700
701 section 23 clock pulse generator 23.1 overview the h8s/2169 and h8s/2149 have a built-in clock pulse generator (cpg) that generates the system clock (?, the bus master clock, and internal clocks. the clock pulse generator consists of an oscillator circuit, a duty-cycle adjustment circuit, clock selection circuit, medium-speed clock divider, bus-master clock selection circuit, subclock input circuit, and waveform shaping circuit. 23.1.1 block diagram figure 23.1 is a block diagram of the clock pulse generator. extal xtal oscillator duty-cycle adjustment circuit excl subclock input circuit waveform shaping circuit medium-speed clock divider system clock to ?pin wdt1 count clock internal clock to supporting modules bus master clock to cpu, dtc ?2 to ?32 sub bus-master clock selection circuit clock selection circuit figure 23.1 block diagram of clock pulse generator 23.1.2 register configuration the clock pulse generator is controlled by the standby control register (sbycr) and low-power control register (lpwrcr). table 23.1 shows the register configuration.
702 table 23.1 cpg registers name abbreviation r/w initial value address * standby control register sbycr r/w h'00 h'ff84 low-power control register lpwrcr r/w h'00 h'ff85 note: * lower 16 bits of the address. 23.2 register descriptions 23.2.1 standby control register (sbycr) 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write sbycr is an 8-bit readable/writable register that performs power-down mode control. only bits 0 to 2 are described here. for a description of the other bits, see section 24.2.1, standby control register (sbycr). sbycr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 2 to 0?ystem clock select 2 to 0 (sck2 to sck0): these bits select the bus master clock for high-speed mode and medium-speed mode. when operating the device after a transition to subactive mode or watch mode bits sck2 to sck0 should all be cleared to 0. bit 2 bit 1 bit 0 sck2 sck1 sck0 description 0 0 0 bus master is in high-speed mode (initial value) 1 medium-speed clock is ?2 1 0 medium-speed clock is ?4 1 medium-speed clock is ?8 1 0 0 medium-speed clock is ?16 1 medium-speed clock is ?32 1
703 23.2.2 low-power control register (lpwrcr) 7 dton 0 r/w r/w 6 lson 0 r/w r/w 5 nesel 0 r/w r/w 4 excle 0 r/w r/w 3 0 r/w 0 0 2 0 1 0 bit initial value read/write (h8s/2169) read/write (h8s/2149) lpwrcr is an 8-bit readable/writable register that performs power-down mode control. only bit 4 is described here. for a description of the other bits, see section 24.2.2, low-power control register (lpwrcr). lpwrcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 4?ubclock input enable (excle): controls subclock input from the excl pin. bit 4 excle description 0 subclock input from excl pin is disabled (initial value) 1 subclock input from excl pin is enabled 23.3 oscillator clock pulses can be supplied by connecting a crystal resonator, or by input of an external clock. 23.3.1 connecting a crystal resonator circuit configuration: a crystal resonator can be connected as shown in the example in figure 23.2. select the damping resistance r d according to table 23.2. an at-cut parallel-resonance crystal should be used.
704 extal xtal r d c l2 c l1 c l1 = c l2 = 10 to 22pf figure 23.2 connection of crystal resonator (example) table 23.2 damping resistance value frequency (mhz) 24810 r d ( w ) 1k 500 200 0 crystal resonator: figure 23.3 shows the equivalent circuit of the crystal resonator. use a crystal resonator that has the characteristics shown in table 23.3 and the same frequency as the system clock (?. xtal c l at-cut parallel-resonance type extal c 0 lr s figure 23.3 crystal resonator equivalent circuit table 23.3 crystal resonator parameters frequency (mhz) 24810 r s max ( w ) 500 120 80 70 c 0 max (pf) 7777 note on board design: when a crystal resonator is connected, the following points should be noted. other signal lines should be routed away from the oscillator circuit to prevent induction from interfering with correct oscillation. see figure 23.4. when designing the board, place the crystal resonator and its load capacitors as close as possible to the xtal and extal pins.
705 c l2 signal a signal b c l1 the chip xtal extal avoid figure 23.4 example of incorrect board design 23.3.2 external clock input circuit configuration: an external clock signal can be input as shown in the examples in figure 23.5. if the xtal pin is left open, make sure that stray capacitance is no more than 10 pf. in example (b), make sure that the external clock is held high in standby mode, subactive mode, subsleep mode, and watch mode. extal xtal external clock input open (a) xtal pin left open extal xtal external clock input (b) complementary clock input at xtal pin figure 23.5 external clock input (examples) external clock: the external clock signal should have the same frequency as the system clock (?.
706 table 23.4 and figure 23.6 show the input conditions for the external clock. table 23.4 external clock input conditions v cc = 2.7 to 3.6 v item symbol min max unit test conditions external clock input low pulse width t exl 40 ns figure 23.6 external clock input high pulse width t exh 40 ns external clock rise time t exr ?0 ns external clock fall time t exf ?0 ns clock low pulse width t cl 0.4 0.6 t cyc ? 3 5 mhz figure 25.4 80 ns < 5 mhz clock high pulse width t ch 0.4 0.6 t cyc ? 3 5 mhz 80 ns < 5 mhz t exh t exl t exr t exf v cc 0.5 extal figure 23.6 external clock input timing table 23.5 shows the external clock output settling delay time, and figure 23.7 shows the external clock output settling delay timing. the oscillator and duty adjustment circuit have a function for adjusting the waveform of the external clock input at the extal pin. when the prescribed clock signal is input at the extal pin, internal clock signal output is fixed after the elapse of the external clock output settling delay time (t dext ). as the clock signal output is not fixed during the t dext period, the reset signal should be driven low to maintain the reset state.
707 table 23.5 external clock output settling delay time conditions: v cc = 2.7 v to 3.6 v, av cc = 2.7 v to 3.6 v, v ss = av ss = 0 v item symbol min max unit notes external clock output settling delay time t dext * 500 m s figure 23.7 note: * t dext includes res pulse width (t resw ). t dext * res (internal or external) extal stby v cc 2.7v v ih ? note: * t dext includes res pulse width (t resw ). figure 23.7 external clock output settling delay timing
708 23.4 duty adjustment circuit when the oscillator frequency is 5 mhz or higher, the duty adjustment circuit adjusts the duty cycle of the clock signal from the oscillator to generate the system clock (?. 23.5 medium-speed clock divider the medium-speed clock divider divides the system clock to generate ?2, ?4, ?8, ?16, and ?32 clocks. 23.6 bus master clock selection circuit the bus master clock selection circuit selects the system clock (? or one of the medium-speed clocks (?2, ?4, ?8, ?16, or ?32) to be supplied to the bus master, according to the settings of bits sck2 to sck0 in sbycr. 23.7 subclock input circuit the subclock input circuit controls the subclock input from the excl pin. inputting the subclock: when a subclock is used, a 32.768 khz external clock should be input from the excl pin. in this case, clear bit p96ddr to 0 in p9ddr and set bit excle to 1 in lpwrcr. the subclock input conditions are shown in table 23.6 and figure 23.8. table 23.6 subclock input conditions v cc = 2.7 to 3.6 v item symbol min typ max unit test conditions subclock input low pulse width t excll 15.26 m s figure 23.8 subclock input high pulse width t exclh 15.26 m s subclock input rise time t exclr 10 ns subclock input fall time t exclf 10 ns
709 t exclh t excll t exclr t exclf v cc 0.5 excl figure 23.8 subclock input timing when subclock is not needed: do not enable subclock input when the subclock is not needed 23.8 subclock waveform shaping circuit to eliminate noise in the subclock input from the excl pin, this circuit samples the clock using a clock obtained by dividing the ?clock. the sampling frequency is set with the nesel bit in lpwrcr. for details, see section 24.2.2, low-power control register (lpwrcr). the clock is not sampled in subactive mode, subsleep mode, or watch mode. 23.9 clock selection circuit this circuit selects the system clock used in the mcu. the clock signal generated in the extal/xtal oscillator is selected as a system clock, when the mcu is returned from high-speed mode, medium-speed mode, sleep mode, reset state, standby mode. in sub-active mode, sub-sleep mode and watch mode, the sub-clock signal input from or excl pin is selected as a sytem clock. in these modes, modules, such as cpu, tmr0, tmr1, wdt0, wdt1, and i/o ports, operate on ?sub clock. in addition, the count clock and sampling clock are derived by frequency division from ?sub. note: see figure 23.1.
710 23.10 x1 and x2 pins leave the x1 and x2 pins open, as shown in figure 23.9. x1 x2 open open figure 23.9 x1 and x2 pins
711 section 24 power-down state 24.1 overview in addition to the normal program execution state, the h8s/2169 or h8s/2149 has a power-down state in which operation of the cpu and oscillator is halted and power dissipation is reduced. low-power operation can be achieved by individually controlling the cpu, on-chip supporting modules, and so on. the h8s/2169 or h8s/2149 operating modes are as follows: 1. high-speed mode 2. medium-speed mode 3. subactive mode 4. sleep mode 5. subsleep mode 6. watch mode 7. module stop mode 8. software standby mode 9. hardware standby mode of these, 2 to 9 are power-down modes. sleep mode and subsleep mode are cpu modes, medium- speed mode is a cpu and bus master mode, subactive mode is a cpu, bus master, and on-chip supporting module mode, and module stop mode is an on-chip supporting module mode (including bus masters other than the cpu). certain combinations of these modes can be set. after a reset, the mcu is in high-speed mode and module stop mode (excluding the dtc). table 24.1 shows the internal chip states in each mode, and table 24.2 shows the conditions for transition to the various modes. figure 24.1 shows a mode transition diagram.
712 table 24.1 the chip? internal states in each mode function high- speed medium- speed sleep module stop watch subactive subsleep software standby hardware standby system clock oscillator function- ing function- ing function- ing function- ing halted halted halted halted halted subclock input function- ing function- ing function- ing function- ing function- ing function- ing function- ing halted halted cpu operation instruc- tions function- ing medium- speed halted function- ing halted subclock operation halted halted halted registers retained retained retained retained undefined external interrupts nmi function- ing function- ing function- ing function- ing function- ing function- ing function- ing function- ing halted irq0 irq1 irq2 on-chip supporting module dtc function- ing medium- speed function- ing function- ing/halted (retained) halted (retained) halted (retained) halted (retained) halted (retained) halted (reset) operation wdt1 function- ing function- ing function- ing function- ing subclock operation subclock operation subclock operation halted (retained) halted (reset) wdt0 halted tmr0, 1 function- ing/halted (retained) frt (retained) halted halted tmrx, y (retained) (retained) timer connec- tion iic0 iic1 hif:lpc sci0 function- ing/halted halted (reset) halted (reset) halted (reset) halted (reset) sci1 (reset) sci2 pwm pwmx hif:xbs, ps2 d/a a/d ram function- ing function- ing function- ing (dtc) function- ing retained function- ing retained retained retained i/o function- ing function- ing function- ing function- ing retained function- ing function- ing retained high impedance note: ?alted (retained)?means that internal register values are retained. the internal state is ?peration suspended. ?alted (reset)?means that internal register values and internal states are initialized. in module stop mode, only modules for which a stop setting has been made are halted (reset or retained).
713 hardware standby mode stby pin = low notes: when a transition is made between modes by means of an interrupt, transition cannot be made on interrupt source generation alone. ensure that interrupt handling is performed after accepting the interrupt request. from any state except hardware standby mode, a transition to the reset state occurs whenever res goes low. from any state, a transition to hardware standby mode occurs when stby goes low. when a transition is made to watch mode or subactive mode, high-speed mode must be set. sleep mode (main clock) ssby = 0, lson = 0 software standby mode ssby = 1 pss = 0, lson = 0 watch mode (subclock) ssby = 1 pss = 1, dton = 0 subsleep mode (subclock) ssby = 0 pss = 1, lson = 1 medium-speed mode (main clock) subactive mode (subclock) high-speed mode (main clock) reset state stby pin = high res pin = low res pin = high program execution state sleep instruction ssby = 1, pss = 1, dton = 1, lson = 0 clock switching exception handling after oscillation setting time (sts2 to sts0) sleep instruction ssby = 1, pss = 1, dton = 1, lson = 1 clock switching exception handling sck2 to sck0 1 0 sck2 to sck0 = 0 program-halted state sleep instruction any interrupt * 3 sleep instruction external interrupt * 4 sleep instruction interrupt * 1 , lson bit = 0 sleep instruction interrupt * 1 , lson bit = 1 interrupt * 2 sleep instruction : transition after exception handling : power-down mode * 1 nmi, irq0 to irq2, irq6, irq7, and wdt1 interrupts * 2 nmi, irq0 to irq7, and wdt0 interrupts, wdt1 interrupt, tmr0 interrupt, tmr1 interrupt * 3 all interrupts * 4 nmi, irq0 to irq2, irq6, irq7 figure 24.1 mode transitions
714 table 24.2 power-down mode transition conditions control bit states at time of transition state before transition ssby pss lson dton state after transition by sleep instruction state after return by interrupt high-speed/ medium-speed 0 * 0 * sleep high-speed/ medium-speed 0 * 1 * 100 * software standby high-speed/ medium-speed 101 * 1100 watch high-speed 1110 watch subactive 1101 1111 subactive subactive 0 0 ** 010 * 011 * subsleep subactive 10 ** 1100 watch high-speed 1110 watch subactive 1101 high-speed 1111 * : don? care ? do not set.
715 24.1.1 register configuration the power-down state is controlled by the sbycr, lpwrcr, tcsr (wdt1), and mstpcr registers. table 24.3 summarizes these registers. table 24.3 power-down state registers name abbreviation r/w initial value address * 1 standby control register sbycr r/w h'00 h'ff84 * 2 low-power control register lpwrcr r/w h'00 h'ff85 * 2 timer control/status register (wdt1) tcsr r/w h'00 h'ffea module stop control register mstpcrh r/w h'3f h'ff86 * 2 mstpcrl r/w h'ff h'ff87 * 2 notes: 1. lower 16 bits of the address. 2. a cpu access to some of the control registers in the power-down state is controlled by the flshe bit of the serial/timer control register (stcr). 24.2 register descriptions 24.2.1 standby control register (sbycr) 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write sbycr is an 8-bit readable/writable register that performs power-down mode control. sbycr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?oftware standby (ssby): determines the operating mode, in combination with other control bits, when a power-down mode transition is made by executing a sleep instruction. the ssby setting is not changed by a mode transition due to an interrupt, etc.
716 bit 7 ssby description 0 transition to sleep mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to subsleep mode after execution of sleep instruction in subactive mode (initial value) 1 transition to software standby mode, subactive mode, or watch mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to watch mode or high-speed mode after execution of sleep instruction in subactive mode bits 6 to 4?tandby timer select 2 to 0 (sts2 to sts0): these bits select the time the mcu waits for the clock to stabilize when software standby mode, watch mode, or subactive mode is cleared and a transition is made to high-speed mode or medium-speed mode by means of a specific interrupt or instruction. with crystal oscillation, refer to table 24.4 and make a selection according to the operating frequency so that the standby time is at least 8 ms (the oscillation settling time). with an external clock, any selection can be made. bit 6 bit 5 bit 4 sts2 sts1 sts0 description 0 0 0 standby time = 8192 states (initial value) 1 standby time = 16384 states 1 0 standby time = 32768 states 1 standby time = 65536 states 1 0 0 standby time = 131072 states 1 standby time = 262144 states 1 0 reserved 1 standby time = 16 states * note: * this setting must not be used in the flash memory version. bit 3?eserved: this bit cannot be modified and is always read as 0.
717 bits 2 to 0?ystem clock select (sck2 to sck0): these bits select the clock for the bus master in high-speed mode and medium-speed mode. when operating the device after a transition to subactive mode or watch mode, bits sck2 to sck0 should all be cleared to 0. bit 2 bit 1 bit 0 sck2 sck1 sck0 description 0 0 0 bus master is in high-speed mode (initial value) 1 medium-speed clock is ?2 1 0 medium-speed clock is ?4 1 medium-speed clock is ?8 1 0 0 medium-speed clock is ?16 1 medium-speed clock is ?32 1 24.2.2 low-power control register (lpwrcr) 7 dton 0 r/w r/w 6 lson 0 r/w r/w 5 nesel 0 r/w r/w 4 excle 0 r/w r/w 3 0 r/w 0 0 2 0 1 0 bit initial value read/write (h8s/2169) read/write (h8s/2149) lpwrcr is an 8-bit readable/writable register that performs power-down mode control. lpwrcr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?irect-transfer on flag (dton): specifies whether a direct transition is made between high-speed mode, medium-speed mode, and subactive mode when making a power-down transition by executing a sleep instruction. the operating mode to which the transition is made after sleep instruction execution is determined by a combination of other control bits.
718 bit 7 dton description 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode (initial value) 1 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made directly to subactive mode * , or a transition is made to sleep mode or software standby mode when a sleep instruction is executed in subactive mode, a transition is made directly to high-speed mode, or a transition is made to subsleep mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. bit 6?ow-speed on flag (lson): determines the operating mode in combination with other control bits when making a power-down transition by executing a sleep instruction. also controls whether a transition is made to high-speed mode or to subactive mode when watch mode is cleared. bit 6 lson description 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * when a sleep instruction is executed in subactive mode, a transition is made to watch mode, or directly to high-speed mode after watch mode is cleared, a transition is made to high-speed mode (initial value) 1 when a sleep instruction is executed in high-speed mode a transition is made to watch mode or subactive mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode after watch mode is cleared, a transition is made to subactive mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. bit 5?oise elimination sampling frequency select (nesel): selects the frequency at which the subclock (?ub) input from the excl pin is sampled with the clock (? generated by the system clock oscillator. when ?= 5 mhz or higher, clear this bit to 0.
719 bit 5 nesel description 0 sampling at ?divided by 32 (initial value) 1 sampling at ?divided by 4 bit 4?ubclock input enable (excle): controls subclock input from the excl pin. bit 4 excle description 0 subclock input from excl pin is disabled (initial value) 1 subclock input from excl pin is enabled bit 3 (h8s/2149)?eserved: these bits cannot be modified and are always read as 0. bit 3 (h8s/2169)?eserved: do not write 1 to this bit. bits 2 to 0?eserved: these bits cannot be modified and are always read as 0. 24.2.3 timer control/status register (tcsr) tcsr1 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write note: * only 0 can be written in bit 7, to clear the flag. tcsr1 is an 8-bit readable/writable register that performs selection of the wdt1 tcnt input clock, mode, etc. only bit 4 is described here. for details of the other bits, see section 14.2.2, timer control/status register (tcsr). tcsr is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode.
720 bit 4?rescaler select (pss): selects the wdt1 tcnt input clock. this bit also controls the operation in a power-down mode transition. the operating mode to which a transition is made after execution of a sleep instruction is determined in combination with other control bits. for details, see the description of clock select 2 to 0 in section 14.2.2, timer control/status register (tcsr). bit 4 pss description 0 tcnt counts ?based prescaler (psm) divided clock pulses when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode or software standby mode (initial value) 1 tcnt counts ?ub-based prescaler (pss) divided clock pulses when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, watch mode * , or subactive mode * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode, watch mode, or high-speed mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. 24.2.4 module stop control register (mstpcr) 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl mstpcr comprises two 8-bit readable/writable registers that perform module stop mode control. mstpcr is initialized to h'3fff by a reset and in hardware standby mode. it is not initialized in software standby mode.
721 mstpcrh and mstpcrl bits 7 to 0?odule stop (mstp 15 to mstp 0): these bits specify module stop mode. see table 24.4 for the method of selecting on-chip supporting modules. mstpcrh, mstpcrl bits 7 to 0 mstp15 to mstp0 description 0 module stop mode is cleared (initial value of mstp15, mstp14) 1 module stop mode is set (initial value of mstp13 to mstp0) 24.3 medium-speed mode when the sck2 to sck0 bits in sbycr are set to 1 in high-speed mode, the operating mode changes to medium-speed mode at the end of the bus cycle. in medium-speed mode, the cpu operates on the operating clock (?2, ?4, ?8, ?16, or ?32) specified by the sck2 to sck0 bits. the bus master other than the cpu (the dtc) also operates in medium-speed mode. on-chip supporting modules other than the bus masters always operate on the high-speed clock (?. in medium-speed mode, a bus access is executed in the specified number of states with respect to the bus master operating clock. for example, if ?4 is selected as the operating clock, on-chip memory is accessed in 4 states, and internal i/o registers in 8 states. medium-speed mode is cleared by clearing all of bits sck2 to sck0 to 0. a transition is made to high-speed mode and medium-speed mode is cleared at the end of the current bus cycle. if a sleep instruction is executed when the ssby bit in sbycr and the lson bit in lpwrcr are cleared to 0, a transition is made to sleep mode. when sleep mode is cleared by an interrupt, medium-speed mode is restored. if a sleep instruction is executed when the ssby bit in sbycr is set to 1, and the lson bit in lpwrcr and the pss bit in tcsr (wdt1) are both cleared to 0, a transition is made to software standby mode. when software standby mode is cleared by an external interrupt, medium-speed mode is restored. when the res pin is driven low, a transition is made to the reset state, and medium-speed mode is cleared. the same applies in the case of a reset caused by overflow of the watchdog timer. when the stby pin is driven low, a transition is made to hardware standby mode. figure 24.2 shows the timing for transition to and clearance of medium-speed mode.
722 bus master clock ? supporting module clock internal address bus internal write signal medium-speed mode sbycr sbycr figure 24.2 medium-speed mode transition and clearance timing 24.4 sleep mode 24.4.1 sleep mode if a sleep instruction is executed when the ssby bit in sbycr and the lson bit in lpwrcr are both cleared to 0, the cpu enters sleep mode. in sleep mode, cpu operation stops but the contents of the cpu? internal registers are retained. other supporting modules do not stop. 24.4.2 clearing sleep mode sleep mode is cleared by any interrupt, or with the res pin or stby pin. clearing with an interrupt: when an interrupt request signal is input, sleep mode is cleared and interrupt exception handling is started. sleep mode will not be cleared if interrupts are disabled, or if interrupts other than nmi have been masked by the cpu. clearing with the res pin: when the res pin is driven low, the reset state is entered. when the res pin is driven high after the prescribed reset input period, the cpu begins reset exception handling. clearing with the stby pin: when the stby pin is driven low, a transition is made to hardware standby mode.
723 24.5 module stop mode 24.5.1 module stop mode module stop mode can be set for individual on-chip supporting modules. when the corresponding mstp bit in mstpcr is set to 1, module operation stops at the end of the bus cycle and a transition is made to module stop mode. the cpu continues operating independently. table 24.4 shows mstp bits and the corresponding on-chip supporting modules. when the corresponding mstp bit is cleared to 0, module stop mode is cleared and the module starts operating again at the end of the bus cycle. in module stop mode, the internal states of modules other than the sci, a/d converter, 8-bit pwm module, and 14-bit pwm module, are retained. after reset release, all modules other than the dtc are in module stop mode. when an on-chip supporting module is in module stop mode, read/write access to its registers is disabled.
724 table 24.4 mstp bits and corresponding on-chip supporting modules register bit module mstpcrh mstp15 * mstp14 data transfer controller (dtc) mstp13 16-bit free-running timer (frt) mstp12 8-bit timers (tmr0, tmr1) mstp11 8-bit pwm timer (pwm), 14-bit pwm timer (pwmx) mstp10 d/a converter mstp9 a/d converter mstp8 8-bit timers (tmrx, tmry), timer connection mstpcrl mstp7 serial communication interface 0 (sci0) mstp6 serial communication interface 1 (sci1) mstp5 serial communication interface 2 (sci2) mstp4 i 2 c bus interface (iic) channel 0 mstp3 i 2 c bus interface (iic) channel 1 mstp2 host interface (hif:xbs), keyboard matrix interrupt mask register (kmimr), keyboard matrix interrupt mask register a (kmimra), port 6 mos pull-up control register (kmpcr), keyboard buffer controller (ps2) mstp1 mstp0 host interface (hif: lpc), keyboard buffer controller (ps2) note: bit 1 can be read or written to, but do not affect operation. * bit 15 must not be set to 1. 24.5.2 usage note if there is conflict between dtc module stop mode setting and a dtc bus request, the bus request has priority and the mstp bit will not be set to 1. write 1 to the mstp bit again after the dtc bus cycle.
725 24.6 software standby mode 24.6.1 software standby mode if a sleep instruction is executed when the ssby bit in sbycr is set to 1, the lson bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is cleared to 0, software standby mode is entered. in this mode, the cpu, on-chip supporting modules, and oscillator all stop. however, the contents of the cpu? internal registers, ram data, and the states of on-chip supporting modules other than the sci, pwm, and pwmx, and of the i/o ports, are retained. in this mode the oscillator stops, and therefore power dissipation is significantly reduced. 24.6.2 clearing software standby mode software standby mode is cleared by an external interrupt (nmi pin, or pin irq0 , irq1 , irq2 , irq6 , or irq7 ), or by means of the res pin or stby pin. clearing with an interrupt: when an nmi, irq0, irq1, irq2, irq6, or irq7 interrupt request signal is input, clock oscillation starts, and after the elapse of the time set in bits sts2 to sts0 in syscr, stable clocks are supplied to the entire chip, software standby mode is cleared, and interrupt exception handling is started. software standby mode cannot be cleared with an irq0, irq1, irq2, irq6, or irq7 interrupt if the corresponding enable bit has been cleared to 0 or has been masked by the cpu. clearing with the res pin: when the res pin is driven low, clock oscillation is started. at the same time as clock oscillation starts, clocks are supplied to the entire chip. note that the res pin must be held low until clock oscillation stabilizes. when the res pin goes high, the cpu begins reset exception handling. clearing with the stby pin: when the stby pin is driven low, a transition is made to hardware standby mode.
726 24.6.3 setting oscillation settling time after clearing software standby mode bits sts2 to sts0 in sbycr should be set as described below. using a crystal oscillator: set bits sts2 to sts0 so that the standby time is at least 8 ms (the oscillation settling time). table 24.5 shows the standby times for different operating frequencies and settings of bits sts2 to sts0. table 24.5 oscillation settling time settings sts2 sts1 sts0 standby time 10 mhz 8 mhz 6 mhz 4 mhz 2 mhz unit 0 0 0 8192 states 0.8 1.0 1.3 2.0 4.1 ms 1 16384 states 1.6 2.0 2.7 4.1 8.2 1 0 32768 states 3.3 4.1 5.5 8.2 16.4 1 65536 states 6.6 8.2 10.9 16.4 32.8 1 0 0 131072 states 13.1 16.4 21.8 32.8 65.5 1 262144 states 26.2 32.8 43.6 65.6 131.2 1 0 reserved m s 1 16 states * 1.6 2.0 2.7 4.0 8.0 : recommended time setting notes: * the maximum operating frequency for the h8s/2169 and h8s/2149 is 10 mhz. this setting must not be used in the flash memory version. using an external clock: any value can be set. normally, use of the minimum time is recommended. 24.6.4 software standby mode application example figure 24.3 shows an example in which a transition is made to software standby mode at the falling edge on the nmi pin, and software standby mode is cleared at the rising edge on the nmi pin. in this example, an nmi interrupt is accepted with the nmieg bit in syscr cleared to 0 (falling edge specification), then the nmieg bit is set to 1 (rising edge specification), the ssby bit is set to 1, and a sleep instruction is executed, causing a transition to software standby mode. software standby mode is then cleared at the rising edge on the nmi pin.
727 oscillator nmi nmieg ssby nmi exception handling nmieg = 1 ssby = 1 sleep instruction software standby mode (power-down state) oscillation settling time t osc2 nmi exception handling figure 24.3 software standby mode application example 24.6.5 usage note in software standby mode, i/o port states are retained. therefore, there is no reduction in current dissipation for the output current when a high-level signal is output. current dissipation increases while waiting for oscillation to settle.
728 24.7 hardware standby mode 24.7.1 hardware standby mode when the stby pin is driven low, a transition is made to hardware standby mode from any mode. in hardware standby mode, all functions enter the reset state and stop operation, resulting in a significant reduction in power dissipation. as long as the prescribed voltage is supplied, on-chip ram data is retained. i/o ports are set to the high-impedance state. in order to retain on-chip ram data, the rame bit in syscr should be cleared to 0 before driving the stby pin low. do not change the state of the mode pins (md1 and md0) while the chip is in hardware standby mode. hardware standby mode is cleared by means of the stby pin and the res pin. when the stby pin is driven high while the res pin is low, the reset state is set and clock oscillation is started. ensure that the res pin is held low until the clock oscillation settles (at least 8 ms?the oscillation settling time?when using a crystal oscillator). when the res pin is subsequently driven high, a transition is made to the program execution state via the reset exception handling state.
729 24.7.2 hardware standby mode timing figure 24.4 shows an example of hardware standby mode timing. when the stby pin is driven low after the res pin has been driven low, a transition is made to hardware standby mode. hardware standby mode is cleared by driving the stby pin high, waiting for the oscillation settling time, then changing the res pin from low to high. oscillator res stby oscillation settling time reset exception handling figure 24.4 hardware standby mode timing
730 24.8 watch mode 24.8.1 watch mode if a sleep instruction is executed in high-speed mode or subactive mode when the ssby in sbycr is set to 1, the dton bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is set to 1, the cpu makes a transition to watch mode. in this mode, the cpu and all on-chip supporting modules except wdt1 stop. as long as the prescribed voltage is supplied, the contents of some of the cpu? internal registers and on-chip ram are retained, and i/o ports retain their states prior to the transition. 24.8.2 clearing watch mode watch mode is cleared by an interrupt (wovi1 interrupt, nmi pin, or pin irq0 , irq1 , irq2 , irq6 , or irq7 ), or by means of the res pin or stby pin. clearing with an interrupt: when an interrupt request signal is input, watch mode is cleared and a transition is made to high-speed mode or medium-speed mode if the lson bit in lpwrcr is cleared to 0, or to subactive mode if the lson bit is set to 1. when making a transition to high- speed mode, after the elapse of the time set in bits sts2 to sts0 in sbycr, stable clocks are supplied to the entire chip, and interrupt exception handling is started. watch mode cannot be cleared with an irq0, irq1, irq2, irq6, or irq7 interrupt if the corresponding enable bit has been cleared to 0, or with an on-chip supporting module interrupt if acceptance of the relevant interrupt has been disabled by the interrupt enable register or masked by the cpu. see section 24.6.3, setting oscillation settling time after clearing software standby mode, for the oscillation settling time setting when making a transition from watch mode to high-speed mode. clearing with the res pin: see ?learing with the res pin in section 24.6.2, clearing software standby mode. clearing with the stby pin: when the stby pin is driven low, a transition is made to hardware standby mode.
731 24.9 subsleep mode 24.9.1 subsleep mode if a sleep instruction is executed in subactive mode when the ssby in sbycr is cleared to 0, the lson bit in lpwrcr is set to 1, and the pss bit in tcsr (wdt1) is set to 1, the cpu makes a transition to subsleep mode. in this mode, the cpu and all on-chip supporting modules except tmr0, tmr1, wdt0, and wdt1 stop. as long as the prescribed voltage is supplied, the contents of some of the cpu? internal registers and on-chip ram are retained, and i/o ports retain their states prior to the transition. 24.9.2 clearing subsleep mode subsleep mode is cleared by an interrupt (on-chip supporting module interrupt, nmi pin, or pin irq0 to irq7 ), or by means of the res pin or stby pin. clearing with an interrupt: when an interrupt request signal is input, subsleep mode is cleared and interrupt exception handling is started. subsleep mode cannot be cleared with an irq0 to irq7 interrupt if the corresponding enable bit has been cleared to 0, or with an on-chip supporting module interrupt if acceptance of the relevant interrupt has been disabled by the interrupt enable register or masked by the cpu. clearing with the res pin: see ?learing with the res pin in section 24.6.2, clearing software standby mode. clearing with the stby pin: when the stby pin is driven low, a transition is made to hardware standby mode
732 24.10 subactive mode 24.10.1 subactive mode if a sleep instruction is executed in high-speed mode when the ssby bit in sbycr, the dton bit in lpwrcr, and the pss bit in tcsr (wdt1) are all set to 1, the cpu makes a transition to subactive mode. when an interrupt is generated in watch mode, if the lson bit in lpwrcr is set to 1, a transition is made to subactive mode. when an interrupt is generated in subsleep mode, a transition is made to subactive mode. in subactive mode, the cpu performs sequential program execution at low speed on the subclock. in this mode, all on-chip supporting modules except tmr0, tmr1, wdt0, and wdt1 stop. when operating the device in subactive mode, bits sck2 to sck0 in sbycr must all be cleared to 0. 24.10.2 clearing subactive mode subsleep mode is cleared by a sleep instruction, or by means of the res pin or stby pin. clearing with a sleep instruction: when a sleep instruction is executed while the ssby bit in sbycr is set to 1, the dton bit in lpwrcr is cleared to 0, and the pss bit in tcsr (wdt1) is set to 1, subactive mode is cleared and a transition is made to watch mode. when a sleep instruction is executed while the ssby bit in sbycr is cleared to 0, the lson bit in lpwrcr is set to 1, and the pss bit in tcsr (wdt1) is set to 1, a transition is made to subsleep mode. when a sleep instruction is executed while the ssby bit in sbycr is set to 1, the dton bit is set to 1 and the lson bit is cleared to 0 in lpwrcr, and the pss bit in tcsr (wdt1) is set to 1, a transition is made directly to high-speed mode. fort details of direct transition, see section 24.11, direct transition. clearing with the res pin: see ?learing with the res pin in section 24.6.2, clearing software standby mode. clearing with the stby pin: when the stby pin is driven low, a transition is made to hardware standby mode
733 24.11 direct transition 24.11.1 overview of direct transition there are three operating modes in which the cpu executes programs: high-speed mode, medium- speed mode, and subactive mode. a transition between high-speed mode and subactive mode without halting the program is called a direct transition. a direct transition can be carried out by setting the dton bit in lpwrcr to 1 and executing a sleep instruction. after the transition, direct transition interrupt exception handling is started. direct transition from high-speed mode to subactive mode: if a sleep instruction is executed in high-speed mode while the ssby bit in sbycr, the lson bit and dton bit in lpwrcr, and the pss bit in tscr (wdt1) are all set to 1, a transition is made to subactive mode. direct transition from subactive mode to high-speed mode: if a sleep instruction is executed in subactive mode while the ssby bit in sbycr is set to 1, the lson bit is cleared to 0 and the dton bit is set to 1 in lpwrcr, and the pss bit in tscr (wdt1) is set to 1, after the elapse of the time set in bits sts2 to sts0 in sbycr, a transition is made to directly to high- speed mode.
734
735 section 25 electrical characteristics 25.1 absolute maximum ratings table 25.1 lists the absolute maximum ratings. table 25.1 absolute maximum ratings item symbol value unit power supply voltage v cc , v cl ?.3 to +4.3 v i/o buffer power supply voltage v cc b ?.3 to +7.0 v input voltage (except ports 6, 7, and a) (include ports c and d for h8s/2169) v in ?.3 to v cc +0.3 v input voltage (cin input not selected for port 6) v in ?.3 to v cc +0.3 v input voltage (cin input not selected for port a) (include ports e, f, and g for h8s/2169) v in ?.3 to v cc b +0.3 v input voltage (cin input selected for port 6) v in ?.3 v to lower of voltages v cc + 0.3 and av cc + 0.3 v input voltage (cin input selected for port a) v in ?.3 v to lower of voltages v cc b + 0.3 and av cc + 0.3 v input voltage (port 7) v in ?.3 to av cc + 0.3 v reference supply voltage av ref ?.3 to av cc + 0.3 v analog power supply voltage av cc ?.3 to +4.3 v analog input voltage v an ?.3 to av cc +0.3 v operating temperature t opr ?0 to +75 c operating temperature (flash memory programming/erasing) t opr ?0 to +75 c storage temperature t stg ?5 to +125 c caution: permanent damage to the chip may result if absolute maximum ratings are exceeded. ensure so that the impressed voltage does not exceed 4.3 v for pins for which the maximum rating is determined by the voltage on the v cc , av cc , and v cl pins, or 7.0 v for pins for which the maximum rating is determined by v cc b.
736 25.2 dc characteristics table 25.2 lists the dc characteristics. permitted output current values and bus drive characteristics are shown in tables 25.3 and 25.4, respectively. table 25.2 dc characteristics conditions: v cc = 2.7 v to 3.6 v* 11 , v cc b = 2.7 v to 5.5 v, av cc * 1 = 2.7 v to 3.6 v, av ref * 1 = 2.7 v to av cc , v ss = av ss * 1 = 0 v, t a = ?0 to +75 c item symbol min typ max unit test conditions schmitt trigger input p67 to p60 * 2, * 6 , kin15 to kin8 * 7 , (1) * 8 v t v cc 0.2 v cc b 0.2 v voltage irq2 to irq0 * 3 , irq5 to irq3 v t + v cc 0.7 v cc b 0.7 v v t + ?v t v cc 0.05 v cc b 0.05 v schmitt trigger input voltage p67 to p60 (kwul = 00) v t v cc 0.2 v (in level switching) * 6 v t + v cc 0.7 v t + ?v t v cc 0.05 p67 to p60 v t v cc 0.3 (kwul = 01) v t + v cc 0.7 v t + ?v t v cc 0.05 p67 to p60 v t v cc 0.4 (kwul = 10) v t + v cc 0.8 v t + ?v t v cc 0.03 p67 to p60 v t v cc 0.45 (kwul = 11) v t + v cc 0.9 v t + ?v t 0.05 input high voltage res , stby , nmi, md1, md0 (2) v ih v cc 0.9 v cc +0.3 v extal v cc 0.7 v cc +0.3 v pa7 to pa0 * 7 (include ports e, f, and g for h8s/2169) v cc b 0.7 v cc b + 0.3 v
737 item symbol min typ max unit test conditions input high voltage port 7 (2) v ih v cc 0.7 av cc +0.3 v input pins except (1) and (2) above (include ports c and d for h8s/2169) v cc 0.7 v cc +0.3 v input low voltage res , stby , md1, md0 (3) v il ?.3 v cc 0.1 v pa7 to pa0 (include ports e, ?.3 v cc b 0.2 v v cc b = 2.7 v to 4.0 v f, and g for h8s/2169) ?.3 0.8 v v cc b = 4.0 v to 5.5 v nmi, extal, input pins except (1) and (3) above (include ports c and d for h8s/2169) ?.3 v cc 0.2 v v cc = 2.7 v to 3.6 v output high voltage all output pins (except p97, and v oh v cc ?0.5 v cc b ?0.5 vi oh = ?00 m a p52 * 4 ) * 5, * 8 (include ports c to g * 8 for h8s/2169) v cc ?1.0 v cc b ?1.0 vi oh = ? ma, (v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 4.5 v) p97, p52 * 4 0.5 vi oh = ?00 m a output low voltage all output pins (except reso ) * 5 (include ports c to g * 8 for h8s/2169) v ol 0.4 v i ol = 1.6 ma ports 1 to 3 1.0 v i ol = 5 ma reso 0.4 v i ol = 1.6 ma input res ? i in 10.0 m av in = 0.5 to leakage current stby , nmi, md1, md0 1.0 m a v cc ?0.5 v port 7 1.0 m av in = 0.5 to av cc ?0.5 v
738 item symbol min typ max unit test conditions three-state leakage current (off state) ports 1 to 6 ports 8, 9, a * 8 , b (include ports c to g * 8 for h8s/2169) i tsi 1.0 m av in = 0.5 to v cc ?0.5 v, v in = 0.5 to v cc b ?0.5 v input pull-up mos ports 1 to 3 i p 5 150 m av in = 0 v, v cc = 2.7 v to 3.6 v current ports 6 (p6pue = 0), b 30 300 m av cc b = 2.7 v to 5.5 v ports a * 8 (include ports c to g * 8 for h8s/2169). 30 600 m a port 6 (p6pue = 1) 3 100 m a input capacitance res (4) c in 80 pf v in = 0 v, f = 1 mhz, nmi 50 pf t a = 25 c p52, p97, p42, p86, pa7 to pa2 20 pf input pins except (4) above (include ports c to g for h8s/2169) 15 pf current dissipation * 9 normal operation i cc 30 40 ma f = 10 mhz sleep mode 20 32 ma f = 10 mhz standby mode * 10 1 5.0 m at a 50 c 20.0 m a50 c < t a analog power during a/d, d/a conversion al cc 1.2 2.0 ma supply current idle 0.01 5.0 m aav cc = 2.0 v to 3.6 v
739 item symbol min typ max unit test conditions reference power during a/d conversion al ref 0.5 1.0 ma supply current during a/d, d/a conversion 2.0 5.0 ma idle 0.01 5.0 m aav ref = 2.0 v to av cc analog power supply voltage * 1 av cc 2.7 3.6 v operating 2.0 3.6 v idle/not used ram standby voltage v ram 2.0 v notes: 1. do not leave the av cc , av ref , and av ss pins open even if the a/d converter and d/a converter are not used. even if the a/d converter and d/a converter are not used, apply a value in the range 2.0 v to 3.6 v to av cc and av ref pins by connection to the power supply (v cc ), or some other method. ensure that av ref av cc . 2. p67 to p60 include supporting module inputs multiplexed on those pins. 3. irq2 includes the adtrg signal multiplexed on that pin. 4. p52/sck0/scl0 and p97/sda0 are nmos push-pull outputs. an external pull-up resistor is necessary to provide high-level output from scl0 and sda0 (ice = 1). p52/sck0 and p97 (ice = 0) high levels are driven by nmos. when the sck0 pin is used as an output, external pull-up register must be connected in order to output high level. 5. when iics = 0, ice = 0, and kbioe = 0. low-level output when the bus drive function is selected is determined separately. 6. the upper limit of the port 6 applied voltage is v cc + 0.3 v when cin input is not selected, and the lower of v cc + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 7. the upper limit of the port a applied voltage is v cc b + 0.3 v when cin input is not selected, and the lower of v cc b + 0.3 v and av cc + 0.3 v when cin input is selected. when a pin is in output mode, the output voltage is equivalent to the applied voltage. 8. the port a characteristics depend on v cc b, and the other pins characteristics depend on v cc . on the h8s/2169, the characteristics of ports e, f, and g depend on v cc b, and the characteristics of ports c and d depend on v cc . 9. current dissipation values are for v ih min = v cc ?0.2 v, v cc b ?0.2 v, and v il max = 0.2 v with all output pins unloaded and the on-chip pull-up moss in the off state. 10. the values are for v ram v cc < 2.7 v, v ih min = v cc ?0.2 v, v cc b ?0.2 v, and v il max = 0.2 v. 11. for flash memory programming/erasure, the applicable range is v cc = 3.0 v to 3.6 v.
740 table 25.3 permissible output currents conditions: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, t a = ?0 to +75 c item symbol min typ max unit permissible output low current (per pin) scl1, scl0, sda1, sda0, ps2ac to ps2cc, ps2ad to ps2cd, pa7 to pa4 (bus drive function selected) i ol 10ma ports 1, 2, 3 2 ma reso 1 ma other output pins 1 ma permissible output low current (total) total of ports 1, 2, and 3 i ol 40ma total of all output pins, including the above 60ma permissible output high current (per pin) all output pins ? oh 2 ma permissible output high current (total) total of all output pins ? oh 30ma notes: 1. to protect chip reliability, do not exceed the output current values in table 25.3. 2. when driving a darlington pair or led, always insert a current-limiting resistor in the output line, as show in figures 25.1 and 25.2.
741 table 25.4 bus drive characteristics conditions: v cc = 2.7 v to 3.6 v, v ss = 0 v, ta = ?0 to +75 c applicable pins: scl1, scl0, sda1, sda0 (bus drive function selected) item symbol min typ max unit test conditions schmitt trigger input voltage v t v cc 0.3 v v cc = 2.7 v to 3.6 v v t + v cc 0.7 v cc = 2.7 v to 3.6 v v t + ?v t v cc 0.05 v cc = 2.7 v to 3.6 v input high voltage v ih v cc 0.7 v cc + 0.5 v v cc = 2.7 v to 3.6 v input low voltage v il ?.5 v cc 0.3 v cc = 2.7 v to 3.6 v output low voltage v ol 0.5 v i ol = 8 ma 0.4 i ol = 3 ma input capacitance c in 20 pf v in = 0 v, f = 1 mhz, t a = 25 c three-state leakage current (off state) | i tsi | 1.0 m av in = 0.5 to v cc ?0.5 v scl, sda output fall time t of 20 + 0.1cb 250 ns v cc = 2.7 v to 3.6 v conditions: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ta = ?0 to +75 c applicable pins: ps2ac, ps2ad, ps2bc, ps2bd, ps2cc, ps2cd, pa7 to pa4 (bus drive function selected) item symbol min typ max unit test conditions output low voltage v ol 0.8 i ol = 16 ma, v cc b = 4.5 v to 5.5 v 0.5 i ol = 8 ma 0.4 i ol = 3 ma
742 2 k w the chip port darlin g ton pair figure 25.1 darlington pair drive circuit (example) 600 w the chip ports 1 to 3 led figure 25.2 led drive circuit (example) 25.3 ac characteristics figure 25.3 shows the test conditions for the ac characteristics. c chip output pin r h r l c = 30 pf: all output ports r l = 2.4 k w r h = 12 k w i/o timing test levels low level: 0.8 v high level: 2.0 v v cc figure 25.3 output load circuit
743 25.3.1 clock timing table 25.5 shows the clock timing. the clock timing specified here covers clock (? output and clock pulse generator (crystal) and external clock input (extal pin) oscillation settling times. for details of external clock input (extal pin and excl pin) timing, see section 23, clock pulse generator. table 25.5 clock timing condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz test item symbol min max unit conditions clock cycle time t cyc 100 500 ns figure 25.4 clock high pulse width t ch 30 ns figure 25.4 clock low pulse width t cl 30 ns clock rise time t cr ?0ns clock fall time t cf ?0ns oscillation settling time at reset (crystal) t osc1 20 ms figure 25.5 oscillation settling time in software standby (crystal) t osc2 8 ms figure 25.6 external clock output stabilization delay time t dext 500 m s t ch t cyc t cf t cl t cr figure 25.4 system clock timing
744 t osc1 t osc1 extal v cc stby res ? t dext t dext figure 25.5 oscillation settling timing nmi irqi (i = 0, 1, 2, 6, 7) t osc2 figure 25.6 oscillation setting timing (exiting software standby mode)
745 25.3.2 control signal timing table 25.6 shows the control signal timing. the only external interrupts that can operate on the subclock (?= 32.768 khz) are nmi and irq0, 1, 2, 6, and 7. table 25.6 control signal timing condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 32.768 khz, 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz test item symbol min max unit conditions res setup time t ress 300 ns figure 25.7 res pulse width t resw 20 t cyc nmi setup time (nmi) t nmis 250 ns figure 25.8 nmi hold time (nmi) t nmih 10 ns nmi pulse width (exiting software standby mode) t nmiw 200 ns irq setup time ( irq7 to irq0 )t irqs 250 ns irq hold time( irq7 to irq0 )t irqh 10 ns irq pulse width ( irq7 , irq6 , irq2 to irq0 ) (exiting software standby mode) t irqw 200 ns
746 t resw t ress t ress res figure 25.7 reset input timing t irqs t nmis t nmih irq edge input nmi t irqs t irqh irqi (i = 7 to 0) irq level input t nmiw t irqw figure 25.8 interrupt input timing
747 25.3.3 bus timing table 25.7 shows the bus timing. operation in external expansion mode is not guaranteed when operating on the subclock (?= 32.768 khz). table 25.7 bus timing (1) (normal mode) condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item symbol min max unit test conditions address delay time t ad 40 ns figure 25.9 to address setup time t as 0.5 ? t cyc ?30 ns figure 25.13 address hold time t ah 0.5 ? t cyc ?20 ns cs delay time ( ios )t csd ?0ns as delay time t asd ?0ns rd delay time 1 t rsd1 ?0ns rd delay time 2 t rsd2 ?0ns read data setup time t rds 35 ns read data hold time t rdh 0ns read data access time 1 t acc1 1.0 ? t cyc ?60 ns read data access time 2 t acc2 1.5 ? t cyc ?50 ns read data access time 3 t acc3 2.0 ? t cyc ?60 ns read data access time 4 t acc4 2.5 ? t cyc ?50 ns read data access time 5 t acc5 3.0 ? t cyc ?60 ns wr delay time 1 t wrd1 ?0ns wr delay time 2 t wrd2 ?0ns wr pulse width 1 t wsw1 1.0 ? t cyc ?40 ns wr pulse width 2 t wsw2 1.5 ? t cyc ?40 ns write data delay time t wdd ?0ns write data setup time t wds 0ns write data hold time t wdh 20 ns wait setup time t wts 60 ns wait hold time t wth 10 ns
748 table 25.7 bus timing (2) (advanced mode) condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition c 10 mhz item symbol min max unit test conditions address delay time t ad 60 ns figure 25.9 to address setup time t as 0.5 ? t cyc ?30 ns figure 25.13 address hold time t ah 0.5 ? t cyc ?20 ns cs delay time ( ios )t csd ?0ns as delay time t asd ?0ns rd delay time 1 t rsd1 ?0ns rd delay time 2 t rsd2 ?0ns read data setup time t rds 35 ns read data hold time t rdh 0ns read data access time 1 t acc1 1.0 ? t cyc ?80 ns read data access time 2 t acc2 1.5 ? t cyc ?50 ns read data access time 3 t acc3 2.0 ? t cyc ?80 ns read data access time 4 t acc4 2.5 ? t cyc ?50 ns read data access time 5 t acc5 3.0 ? t cyc ?80 ns wr delay time 1 t wrd1 ?0ns wr delay time 2 t wrd2 ?0ns wr pulse width 1 t wsw1 1.0 ? t cyc ?40 ns wr pulse width 2 t wsw2 1.5 ? t cyc ?40 ns write data delay time t wdd ?0ns write data setup time t wds 0ns write data hold time t wdh 20 ns wait setup time t wts 60 ns wait hold time t wth 10 ns
749 t rsd2 t 1 t ad t csd as * a23 to a0, ios * note: * as and ios are the same pin. the function is selected by the iose bit in syscr. t asd rd (read) t 2 t as t asd t acc2 t rsd1 t acc3 t rds t wrd2 t wrd2 t wdd t wsw1 t wdh d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t ah t ah t as t as t rdh figure 25.9 basic bus timing (two-state access)
750 t rsd2 t 2 as * a23 to a0, ios * t asd rd (read) t 3 t as t asd t acc4 t rsd1 t acc5 t rds t wrd1 t wrd2 t wds t wsw2 t wdh d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t 1 t wdd t ad t csd note: * as and ios are the same pin. the function is selected b y the iose bit in syscr. t ah t ah t as t rdh figure 25.10 basic bus timing (three-state access)
751 t w as * a23 to a0, ios * rd (read) t 3 d15 to d0 (read) hwr , lwr (write) d15 to d0 (write) t 2 t wts t 1 t wth t wts t wth wait note: * as and ios are the same pin. the function is selected b y the iose bit in syscr. figure 25.11 basic bus timing (three-state access with one wait state)
752 t rsd2 t 1 as * a23 to a0, ios * t 2 t ah t acc3 t rds d15 to d0 (read) t 2 or t 3 t as t 1 t asd t asd t rdh t ad rd (read) note: * as and ios are the same pin. the function is selected b y the iose bit in syscr. figure 25.12 burst rom access timing (two-state access)
753 t rsd2 t 1 as * a23 to a0, ios * t 1 t acc1 d15 to d0 (read) t 2 or t 3 t rdh t ad rd (read) t rds note: * as and ios are the same pin. the function is selected by the iose bit in syscr. figure 25.13 burst rom access timing (one-state access)
754 25.3.4 timing of on-chip supporting modules tables 25.8 to 25.10 show the on-chip supporting module timing. the only on-chip supporting modules that can operate in subclock operation (?= 32.768 khz) are the i/o ports, external interrupts (nmi and irq0, 1, 2, 6, and 7), the watchdog timer, and the 8-bit timer (channels 0 and 1). table 25.8 timing of on-chip supporting modules (1) condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 32.768 khz * , 2?hz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item symbol min max unit test conditions i/o ports output data delay time t pwd 100 ns figure 25.14 input data setup time t prs 50 input data hold time t prh 50 frt timer output delay time t ftod 100 ns figure 25.15 timer input setup time t ftis 50 timer clock input setup time t ftcs 50 figure 25.16 timer clock single edge t ftcwh 1.5 t cyc pulse width both edges t ftcwl 2.5 tmr timer output delay time t tmod 100 ns figure 25.17 timer reset input setup time t tmrs 50 figure 25.19 timer clock input setup time t tmcs 50 figure 25.18 timer clock single edge t tmcwh 1.5 t cyc pulse width both edges t tmcwl 2.5 pwm, pwmx pulse output delay time t pwod 100 ns figure 25.20 sci input clock asynchronous t scyc 4t cyc figure 25.21 cycle synchronous 6 input clock pulse width t sckw 0.4 0.6 t scyc input clock rise time t sckr 1.5 t cyc input clock fall time t sckf 1.5 transmit data delay time (synchronous) t txd 100 ns figure 25.22
755 condition 10 mhz item symbol min max unit test conditions sci receive data setup time (synchronous) t rxs 100 ns figure 25.22 receive data hold time (synchronous) t rxh 100 ns a/d converter trigger input setup time t trgs 50 ns figure 25.23 wdt reso output delay time t resd 200 ns figure 25.24 reso output pulse width t resow 132 t cyc note: * only supporting modules that can be used in subclock operation ports 1 to 9, a to g (read) t 2 t 1 t pwd t prh t prs ports 1 to 6, 8, 9, a to g (write) figure 25.14 i/o port input/output timing t ftis t ftod ftoa, ftob ftia, ftib, ftic, ftid figure 25.15 frt input/output timing
756 t ftcs ftci t ftcwh t ftcwl figure 25.16 frt clock input timing tmo0, tmo1 tmox t tmod figure 25.17 8-bit timer output timing tmci0, tmci1 tmix, tmiy t tmcs t tmcs t tmcwh t tmcwl figure 25.18 8-bit timer clock input timing tmri0, tmri1 tmix, tmiy t tmrs figure 25.19 8-bit timer reset input timing
757 pw15 to pw0, pwx1, pwx0 t pwod figure 25.20 pwm, pwmx output timing sck0 to sck2 t sckw t sckr t sckf t scyc figure 25.21 sck clock input timing txd0 to txd2 (transmit data) rxd0 to rxd2 (receive data) sck0 to sck2 t rxs t rxh t txd figure 25.22 sci input/output timing (synchronous mode) adtrg t trgs figure 25.23 a/d converter external trigger input timing
758 t resow t resd t resd reso figure 25.24 wdt output timing ( reso ) table 25.8 timing of on-chip supporting modules (2) condition: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item symbol min max unit test conditions xbs read cs /ha0 setup time t har 10 ns figure 25.25 cycle cs /ha0 hold time t hra 10 ns ior pulse width t hrpw 220 ns hdb delay time t hrd 200 ns hdb hold time t hrf 040ns hirq delay time t hirq 200 ns xbs write cs /ha0 setup time t haw 10 ns cycle cs /ha0 hold time t hwa 10 ns iow pulse width t hwpw 100 ns hdb setup time fast a20 gate not used t hdw 50 ns fast a20 gate used 85 ns hdb hold time t hwd 25 ns ga20 delay time t hga 180 ns
759 cs /ha0 ior hdb7 to hdb0 valid data hirqi * (i = 1, 11, 12, 3, 4) t har t hrpw t hra t hrf t hirq t hrd cs /ha0 iow hdb7 to hdb0 ga20 t haw t hwpw t hwa t hwd t hga t hdw host interface (xbs) read timing note: * the rising edge timing is the same as the port 4 and port b output timing. see figure 25.14. host interface (xbs) write timing figure 25.25 host interface (xbs) timing
760 table 25.9 keyboard buffer controller timing conditions: v cc = 2.7 v to 3.6 v, v cc b = 2.7 v to 5.5 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c ratings item symbol min typ max unit notes kclk, kd output fall time t kbf 20 + 0.1cb 250 ns figure 25.26 kclk, kd input data hold time t kbih 150 ns kclk, kd input data setup time t kbis 150 ns kclk, kd output delay time t kbod 450 ns kclk, kd capacitive load c b 400 pf 1. reception kclk/ kd * kclk/ kd * t kbis t kbih transmission (b) t kbf 2. transmission (a) kclk/ kd * t1 t2 t kbod note: ?shown here is the clock scaled by 1/n when the operating mode is active medium-speed mode. * kclk: ps2ac to ps2cc kd: ps2ad to ps2cd figure 25.26 keyboard buffer controller timing
761 table 25.10 i 2 c bus timing conditions: v cc = 2.7 v to 3.6 v, v ss = 0 v, ?= 5 mhz to maximum operating frequency, t a = ?0 to +75 c ratings item symbol min typ max unit notes scl input cycle time t scl 12t cyc figure 25.27 scl input high pulse width t sclh 3 t cyc scl input low pulse width t scll 5 t cyc scl, sda input rise time t sr 7.5 * t cyc scl, sda input fall time t sf 300 ns scl, sda input spike pulse elimination time t sp 1 t cyc sda input bus free time t buf 5 t cyc start condition input hold time t stah 3 t cyc retransmission start condition input setup time t stas 3 t cyc stop condition input setup time t stos 3 t cyc data input setup time t sdas 0.5 t cyc data input hold time t sdah 0 ns scl, sda capacitive load c b 400 pf note: * 17.5t cyc can be set according to the clock selected for use by the i 2 c module. for details, see section 16.4, usage notes.
762 sda0, sda1 v il v ih t buf p * p * s * t stah t sclh t sr t scll t scl t sf t sdah sr * t sdas t stas t sp t stos note: * s, p, and sr indicate the following conditions. s: p: sr: start condition stop condition retransmission start condition scl0, scl1 figure 25.27 i 2 c bus interface input/output timing table 25.11 lpc module timing conditions: v cc = 3.0 v to 3.6 v, v ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c item symbol min max unit notes lpc input clock cycle t lcyc 30 ns figure 25.28 input clock pulse width t lckw 0.4 0.6 t lcyc transmit signal delay time t txd ?8ns receive signal setup time t rxs 8 receive signal hold time t rxh 8
763 lclk lad3 to lad0, serirq (transmit signal) lad3 to lad0, serirq, lframe , lreset (receive signal) t txd t rxh t rxs t lcyc t lckw lclk figure 25.28 host interface (lpc) timing
764 25.4 a/d conversion characteristics tables 25.12 and 25.13 list the a/d conversion characteristics. table 25.12 a/d conversion characteristics (an7 to an0 input: 134/266-state conversion) condition: v cc = 2.7 v to 3.6 v, av cc = 2.7 v to 3.6 v, av ref = 2.7 v to av cc , v cc b = 2.7 v to 5.5 v, v ss = av ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item min typ max unit resolution 10 10 10 bits conversion time 13.4 m s analog input capacitance 20 pf permissible signal-source impedance 5 k w nonlinearity error 7.0 lsb offset error 7.5 lsb full-scale error 7.5 lsb quantization error 0.5 lsb absolute accuracy 8.0 lsb
765 table 25.13 a/d conversion characteristics (cin15 to cin0 input: 134/266-state conversion) condition: v cc = 3.0 v to 3.6 v, av cc = 3.0 v to 3.6 v, av ref = 3.0 v to av cc , v cc b = 3.0 v to 5.5 v, v ss = av ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item min typ max unit resolution 10 10 10 bits conversion time 13.4 m s analog input capacitance 20 pf permissible signal-source impedance 5 k w nonlinearity error 11.0 lsb offset error 11.5 lsb full-scale error 11.5 lsb quantization error 0.5 lsb absolute accuracy 12.0 lsb 25.5 d/a conversion characteristics table 25.14 lists the d/a conversion characteristics. table 25.14 d/a conversion characteristics condition: v cc = 2.7 v to 3.6 v, av cc = 2.7 v to 3.6 v, av ref = 2.7 v to av cc , v cc b = 2.7 v to 5.5 v, v ss = av ss = 0 v, ?= 2 mhz to maximum operating frequency, t a = ?0 to +75 c condition 10 mhz item min typ max unit resolution 8 8 8 bits conversion time with 20 pf load capacitance 10 m s absolute accuracy with 2 m w load resistance 2.0 3.0 lsb with 4 m w load resistance 2.0
766 25.6 flash memory characteristics table 25.15 shows the flash memory characteristics. table 25.15 flash memory characteristics condition: v cc = 3.0 v to 3.6 v, v ss = 0 v, t a = ?0 to +75 c item symbol min typ max unit test condition programming time * 1, * 2, * 4 tp 10 200 ms/ 128 bytes erase time * 1, * 3, * 6 te 100 1200 ms/ block reprogramming count n wec 100 times programming wait time after swe-bit setting * 1 x1 m s wait time after psu-bit setting * 1 y50 m s wait time after z1 28 30 32 m s1 n 6 p-bit setting * 1, * 4 z2 198 200 202 m s7 n 1000 z3 8 10 12 m s additional write wait time after p-bit clear * 1 a 5 m s wait time after psu-bit clear * 1 b 5 m s wait time after pv-bit setting * 1 g 4 m s wait time after dummy write * 1 e 2 m s wait time after pv-bit clear * 1 h 2 m s wait time after swe-bit clear * 1 q 100 m s maximum programming count * 1, * 4, * 5 n 1000 times
767 item symbol min typ max unit test condition erase wait time after swe-bit setting * 1 x1 m s wait time after esu-bit setting * 1 y 100 m s wait time after e-bit setting * 1, * 6 z 10 100 ms wait time after e-bit clear * 1 a 10 m s wait time after esu-bit clear * 1 b 10 m s wait time after ev-bit setting * 1 g 20 m s wait time after dummy write * 1 e 2 m s wait time after ev-bit clear * 1 h 4 m s wait time after swe-bit clear * 1 q 100 m s maximum erase count * 1, * 6, * 7 n 120 times notes: 1. set the times according to the program/erase algorithms. 2. programming time per 128 bytes (shows the total period for which the p-bit in flmcr1 is set. it does not include the programming verification time.) 3. block erase time (shows the total period for which the e-bit in flmcr1 is set. it does not include the erase verification time.) 4. maximum programming time (tp (max)) tp (max) = (wait time after p-bit setting (z1) + (z3)) 6 + wait time after p-bit setting (z2) ((n) ?6) 5. the maximun number of writes (n) should be set according to the actual set value of z1, z2 and z3 to allow programming within the maximum programming time (tp (max)). the wait time after p-bit setting (z1,z2, and z3) should be alternated according to the number of writes (n) as follows: 1 n 6 z1 = 30 m s, z3 = 10 m s 7 n 1000 z2 = 200 m s 6. maximum erase time (te (max)) te (max) = wait time after e-bit setting (z) maximum erase count (n) 7. the maximum number of erases (n) should be set according to the actual set value of z to allow erasing within the maximum erase time (te (max)).
768 25.7 usage note the method of connecting an external capacitor is shown in figure 25.29. connect the system power supply to the vcl pin together with the vcc pins. vcl vss h8s/2169, h8s/2149 0.01 f 10 f bypass capacitor vcc power supply < vcc = 2.7 v to 3.6 v > connect the vcc power supply to the chip's vcl pin in the same way as the vcc pins. it is recommended that a bypass capacitor be connected to the power supply pins. (values are reference values.) figure 25.29 connection of vcl capacitor
769 appendix a instruction set a.1 instruction operation notation rd general register (destination ) * 1 rs general register (source) * 1 rn general register * 1 ern general register (32-bit register) mac multiply-and-accumulate register (32-bit register) * 2 (ead) destination operand (eas) source operand exr extend register ccr condition code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition subtraction multiplication division logical and logical or exclusive logical or transfer from left-hand operand to right-hand operand, or transition from left- hand state to right-hand state not (logical complement) ( ) < > operand contents :8/:16/:24/:32 8-, 16-, 24-, or 32-bit length notes: 1. general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit registers (er0 to er7). 2. mac instructions cannot be used in the h8s/2149.
770 condition code notation symbol meaning changes according operation result. * indeterminate (value not guaranteed). 0 always cleared to 0. 1 always set to 1. not affected by operation result.
771 table a.1 instruction set 1. data transfer instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mov mov.b #xx:8,rd mov.b rs,rd mov.b @ers,rd mov.b @(d:16,ers),rd mov.b @(d:32,ers),rd mov.b @ers+,rd mov.b @aa:8,rd mov.b @aa:16,rd mov.b @aa:32,rd mov.b rs,@erd mov.b rs,@(d:16,erd) mov.b rs,@(d:32,erd) mov.b rs,@-erd mov.b rs,@aa:8 mov.b rs,@aa:16 mov.b rs,@aa:32 mov.w #xx:16,rd mov.w rs,rd mov.w @ers,rd mov.w @(d:16,ers),rd mov.w @(d:32,ers),rd mov.w @ers+,rd mov.w @aa:16,rd mov.w @aa:32,rd mov.w rs,@erd mov.w rs,@(d:16,erd) mov.w rs,@(d:32,erd) mov.w rs,@-erd mov.w rs,@aa:16 mov.w rs,@aa:32 #xx:8 ? rd8 rs8 ? rd8 @ers ? rd8 @(d:16,ers) ? rd8 @(d:32,ers) ? rd8 @ers ? rd8,ers32+1 ? ers32 @aa:8 ? rd8 @aa:16 ? rd8 @aa:32 ? rd8 rs8 ? @erd rs8 ? @(d:16,erd) rs8 ? @(d:32,erd) erd32-1 ? erd32,rs8 ? @erd rs8 ? @aa:8 rs8 ? @aa:16 rs8 ? @aa:32 #xx:16 ? rd16 rs16 ? rd16 @ers ? rd16 @(d:16,ers) ? rd16 @(d:32,ers) ? rd16 @ers ? rd16,ers32+2 ? ers32 @aa:16 ? rd16 @aa:32 ? rd16 rs16 ? @erd rs16 ? @(d:16,erd) rs16 ? @(d:32,erd) erd32-2 ? erd32,rs16 ? @erd rs16 ? @aa:16 rs16 ? @aa:32 b b b b b b b b b b b b b b b b w w w w w w w w w w w w w w 2 4 2 2 2 2 2 2 4 8 4 8 4 8 4 8 2 2 2 2 2 4 6 2 4 6 4 6 4 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 3 5 3 2 3 4 2 3 5 3 2 3 4 2 1 2 3 5 3 3 4 2 3 5 3 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
772 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mov pop push ldm * 4 stm * 4 movfpe movtpe mov.l #xx:32,erd mov.l ers,erd mov.l @ers,erd mov.l @(d:16,ers),erd mov.l @(d:32,ers),erd mov.l @ers+,erd mov.l @aa:16,erd mov.l @aa:32,erd mov.l ers,@erd mov.l ers,@(d:16,erd) mov.l ers,@(d:32,erd) mov.l ers,@-erd mov.l ers,@aa:16 mov.l ers,@aa:32 pop.w rn pop.l ern push.w rn push.l ern ldm @sp+,(erm-ern) stm (erm-ern),@-sp movfpe @aa:16,rd movtpe rs,@aa:16 #xx:32 ? erd32 ers32 ? erd32 @ers ? erd32 @(d:16,ers) ? erd32 @(d:32,ers) ? erd32 @ers ? erd32,ers32+4 ? ers32 @aa:16 ? erd32 @aa:32 ? erd32 ers32 ? @erd ers32 ? @(d:16,erd) ers32 ? @(d:32,erd) erd32-4 ? erd32,ers32 ? @erd ers32 ? @aa:16 ers32 ? @aa:32 @sp ? rn16,sp+2 ? sp @sp ? ern32,sp+4 ? sp sp-2 ? sp,rn16 ? @sp sp-4 ? sp,ern32 ? @sp (@sp ? ern32,sp+4 ? sp) repeated for each restored register. (sp-4 ? sp,ern32 ? @sp) repeated for each saved register. l l l l l l l l l l l l l l w l w l l l 6 2 4 4 6 10 6 10 4 4 6 8 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3 1 4 5 7 5 5 6 4 5 7 5 5 6 3 5 3 5 7/9/11 [1] 7/9/11 [1] [2] [2] 2 4 2 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size cannot be used with the lsi.
773 2. arithmetic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc add addx adds inc daa sub subx subs dec add.b #xx:8,rd add.b rs,rd add.w #xx:16,rd add.w rs,rd add.l #xx:32,erd add.l ers,erd addx #xx:8,rd addx rs,rd adds #1,erd adds #2,erd adds #4,erd inc.b rd inc.w #1,rd inc.w #2,rd inc.l #1,erd inc.l #2,erd daa rd sub.b rs,rd sub.w #xx:16,rd sub.w rs,rd sub.l #xx:32,erd sub.l ers,erd subx #xx:8,rd subx rs,rd subs #1,erd subs #2,erd subs #4,erd dec.b rd dec.w #1,rd dec.w #2,rd dec.l #1,erd dec.l #2,erd rd8+#xx:8 ? rd8 rd8+rs8 ? rd8 rd16+#xx:16 ? rd16 rd16+rs16 ? rd16 erd32+#xx:32 ? erd32 erd32+ers32 ? erd32 rd8+#xx:8+c ? rd8 rd8+rs8+c ? rd8 erd32+1 ? erd32 erd32+2 ? erd32 erd32+4 ? erd32 rd8+1 ? rd8 rd16+1 ? rd16 rd16+2 ? rd16 erd32+1 ? erd32 erd32+2 ? erd32 rd8 decimal adjust ? rd8 rd8-rs8 ? rd8 rd16-#xx:16 ? rd16 rd16-rs16 ? rd16 erd32-#xx:32 ? erd32 erd32-ers32 ? erd32 rd8-#xx:8-c ? rd8 rd8-rs8-c ? rd8 erd32-1 ? erd32 erd32-2 ? erd32 erd32-4 ? erd32 rd8-1 ? rd8 rd16-1 ? rd16 rd16-2 ? rd16 erd32-1 ? erd32 erd32-2 ? erd32 b b w w l l b b l l l b w w l l b b w w l l b b l l l b w w l l 2 4 6 2 4 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 ? ? ? * [3] [3] [4] [4] * [3] [3] [4] [4] operation condition code no. of states * 1 normal advanced [5] [5] [5] [5] size
774 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc das mulxu mulxs divxu divxs cmp neg extu exts tas das rd mulxu.b rs,rd mulxu.w rs,erd mulxs.b rs,rd mulxs.w rs,erd divxu.b rs,rd divxu.w rs,erd divxs.b rs,rd divxs.w rs,erd cmp.b #xx:8,rd cmp.b rs,rd cmp.w #xx:16,rd cmp.w rs,rd cmp.l #xx:32,erd cmp.l ers,erd neg.b rd neg.w rd neg.l erd extu.w rd extu.l erd exts.w rd exts.l erd tas @erd * 2 rd8 decimal adjust ? rd8 rd8 rs8 ? rd16 (unsigned multiplication) rd16 rs16 ? erd32 (unsigned multiplication) rd8 rs8 ? rd16 (signed multiplication) rd16 rs16 ? erd32 (signed multiplication) rd16 ? rs8 ? rd16 (rdh: remainder, rdl: quotient) (unsigned division) erd32 ? rs16 ? erd32 (ed: remainder, rd: quotient) (unsigned division) rd16 ? rs8 ? rd16 (rdh: remainder, rdl: quotient) (signed division) erd32 ? rs16 ? erd32 (ed: remainder, rd: quotient) (signed division) rd8-#xx:8 rd8-rs8 rd16-#xx:16 rd16-rs16 erd32-#xx:32 erd32-ers32 0-rd8 ? rd8 0-rd16 ? rd16 0-erd32 ? erd32 0 ? ( of rd16) 0 ? ( of erd32) ( of rd16) ? ( of rd16) ( of erd32) ? ( of erd32) erd-0 ? ccr set, (1) ? ( of @erd) b b w b w b w b w b b w w l l b w l w l w l b 2 2 2 4 4 2 2 4 4 2 2 2 2 2 2 2 2 2 2 1 12 20 13 21 12 20 13 21 1 1 2 1 3 1 1 1 1 1 1 1 1 4 ? ? operation condition code no. of states * 1 normal advanced * size * 4 2 4 6 [7] [6] [7] [6] [7] [8] [7] [8] [3] [3] [4] [4] 0 0 0 0 0 0 0
775 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc mac clrmac ldmac stmac mac @ern+,@erm+ clrmac ldmac ers,mach ldmac ers,macl stmac mach,erd stmac macl,erd cannot be used with the lsi. [2] operation condition code no. of states * 1 normal advanced size
776 3. logic instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc and or xor not and.b #xx:8,rd and.b rs,rd and.w #xx:16,rd and.w rs,rd and.l #xx:32,erd and.l ers,erd or.b #xx:8,rd or.b rs,rd or.w #xx:16,rd or.w rs,rd or.l #xx:32,erd or.l ers,erd xor.b #xx:8,rd xor.b rs,rd xor.w #xx:16,rd xor.w rs,rd xor.l #xx:32,erd xor.l ers,erd not.b rd not.w rd not.l erd rd8 #xx:8 ? rd8 rd8 rs8 ? rd8 rd16 #xx:16 ? rd16 rd16 rs16 ? rd16 erd32 #xx:32 ? erd32 erd32 ers32 ? erd32 rd8 #xx:8 ? rd8 rd8 rs8 ? rd8 rd16 #xx:16 ? rd16 rd16 rs16 ? rd16 erd32 #xx:32 ? erd32 erd32 ers32 ? erd32 rd8 ? #xx:8 ? rd8 rd8 ? rs8 ? rd8 rd16 ? #xx:16 ? rd16 rd16 ? rs16 ? rd16 erd32 ? #xx:32 ? erd32 erd32 ? ers32 ? erd32 a rd8 ? rd8 a rd16 ? rd16 a erd32 ? erd32 b b w w l l b b w w l l b b w w l l b w l 2 4 6 2 4 6 2 4 6 2 2 4 2 2 4 2 2 4 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 2 1 3 2 1 1 2 1 3 2 1 1 2 1 3 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
777 4. shift instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc shal shar shll shlr rotxl shal.b rd shal.b #2,rd shal.w rd shal.w #2,rd shal.l erd shal.l #2,erd shar.b rd shar.b #2,rd shar.w rd shar.w #2,rd shar.l erd shar.l #2,erd shll.b rd shll.b #2,rd shll.w rd shll.w #2,rd shll.l erd shll.l #2,erd shlr.b rd shlr.b #2,rd shlr.w rd shlr.w #2,rd shlr.l erd shlr.l #2,erd rotxl.b rd rotxl.b #2,rd rotxl.w rd rotxl.w #2,rd rotxl.l erd rotxl.l #2,erd b b w w l l b b w w l l b b w w l l b b w w l l b b w w l l 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 operation condition code no. of states * 1 normal advanced size c msb lsb 0 c 0 msb lsb 0 c msb lsb c msb lsb c msb lsb
778 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc rotxr rotl rotr rotxr.b rd rotxr.b #2,rd rotxr.w rd rotxr.w #2,rd rotxr.l erd rotxr.l #2,erd rotl.b rd rotl.b #2,rd rotl.w rd rotl.w #2,rd rotl.l erd rotl.l #2,erd rotr.b rd rotr.b #2,rd rotr.w rd rotr.w #2,rd rotr.l erd rotr.l #2,erd b b w w l l b b w w l l b b w w l l 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 operation condition code no. of states * 1 normal advanced size c msb lsb c msb lsb c msb lsb
779 5. bit manipulation instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc bset bclr bnot bset #xx:3,rd bset #xx:3,@erd bset #xx:3,@aa:8 bset #xx:3,@aa:16 bset #xx:3,@aa:32 bset rn,rd bset rn,@erd bset rn,@aa:8 bset rn,@aa:16 bset rn,@aa:32 bclr #xx:3,rd bclr #xx:3,@erd bclr #xx:3,@aa:8 bclr #xx:3,@aa:16 bclr #xx:3,@aa:32 bclr rn,rd bclr rn,@erd bclr rn,@aa:8 bclr rn,@aa:16 bclr rn,@aa:32 bnot #xx:3,rd bnot #xx:3,@erd bnot #xx:3,@aa:8 bnot #xx:3,@aa:16 bnot #xx:3,@aa:32 bnot rn,rd bnot rn,@erd bnot rn,@aa:8 bnot rn,@aa:16 bnot rn,@aa:32 (#xx:3 of rd8) ? 1 (#xx:3 of @erd) ? 1 (#xx:3 of @aa:8) ? 1 (#xx:3 of @aa:16) ? 1 (#xx:3 of @aa:32) ? 1 (rn8 of rd8) ? 1 (rn8 of @erd) ? 1 (rn8 of @aa:8) ? 1 (rn8 of @aa:16) ? 1 (rn8 of @aa:32) ? 1 (#xx:3 of rd8) ? 0 (#xx:3 of @erd) ? 0 (#xx:3 of @aa:8) ? 0 (#xx:3 of @aa:16) ? 0 (#xx:3 of @aa:32) ? 0 (rn8 of rd8) ? 0 (rn8 of @erd) ? 0 (rn8 of @aa:8) ? 0 (rn8 of @aa:16) ? 0 (rn8 of @aa:32) ? 0 (#xx:3 of rd8) ? [a (#xx:3 of rd8)] (#xx:3 of @erd) ? [a (#xx:3 of @erd)] (#xx:3 of @aa:8) ? [a (#xx:3 of @aa:8)] (#xx:3 of @aa:16) ? [a (#xx:3 of @aa:16)] (#xx:3 of @aa:32) ? [a (#xx:3 of @aa:32)] (rn8 of rd8) ? [a (rn8 of rd8)] (rn8 of @erd) ? [a (rn8 of @erd)] (rn8 of @aa:8) ? [a (rn8 of @aa:8)] (rn8 of @aa:16) ? [a (rn8 of @aa:16)] (rn8 of @aa:32) ? [a (rn8 of @aa:32)] b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 1 4 4 5 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
780 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc btst bld bild bst bist btst #xx:3,rd btst #xx:3,@erd btst #xx:3,@aa:8 btst #xx:3,@aa:16 btst #xx:3,@aa:32 btst rn,rd btst rn,@erd btst rn,@aa:8 btst rn,@aa:16 btst rn,@aa:32 bld #xx:3,rd bld #xx:3,@erd bld #xx:3,@aa:8 bld #xx:3,@aa:16 bld #xx:3,@aa:32 bild #xx:3,rd bild #xx:3,@erd bild #xx:3,@aa:8 bild #xx:3,@aa:16 bild #xx:3,@aa:32 bst #xx:3,rd bst #xx:3,@erd bst #xx:3,@aa:8 bst #xx:3,@aa:16 bst #xx:3,@aa:32 bist #xx:3,rd bist #xx:3,@erd bist #xx:3,@aa:8 bist #xx:3,@aa:16 bist #xx:3,@aa:32 ?(#xx:3 of rd8) ? z a (#xx:3 of @erd) ? z a (#xx:3 of @aa:8) ? z a (#xx:3 of @aa:16) ? z a (#xx:3 of @aa:32) ? z a (rn8 of rd8) ? z a (rn8 of @erd) ? z a (rn8 of @aa:8) ? z a (rn8 of @aa:16) ? z a (rn8 of @aa:32) ? z (#xx:3 of rd8) ? c (#xx:3 of @erd) ? c (#xx:3 of @aa:8) ? c (#xx:3 of @aa:16) ? c (#xx:3 of @aa:32) ? c a (#xx:3 of rd8) ? c a (#xx:3 of @erd) ? c a (#xx:3 of @aa:8) ? c a (#xx:3 of @aa:16) ? c a (#xx:3 of @aa:32) ? c c ? (#xx:3 of rd8) c ? (#xx:3 of @erd) c ? (#xx:3 of @aa:8) c ? (#xx:3 of @aa:16) c ? (#xx:3 of @aa:32) a c ? (#xx:3 of rd8) a c ? (#xx:3 of @erd) a c ? (#xx:3 of @aa:8) a c ? (#xx:3 of @aa:16) a c ? (#xx:3 of @aa:32) b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 4 4 5 6 1 4 4 5 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
781 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc band biand bor bior bxor bixor band #xx:3,rd band #xx:3,@erd band #xx:3,@aa:8 band #xx:3,@aa:16 band #xx:3,@aa:32 biand #xx:3,rd biand #xx:3,@erd biand #xx:3,@aa:8 biand #xx:3,@aa:16 biand #xx:3,@aa:32 bor #xx:3,rd bor #xx:3,@erd bor #xx:3,@aa:8 bor #xx:3,@aa:16 bor #xx:3,@aa:32 bior #xx:3,rd bior #xx:3,@erd bior #xx:3,@aa:8 bior #xx:3,@aa:16 bior #xx:3,@aa:32 bxor #xx:3,rd bxor #xx:3,@erd bxor #xx:3,@aa:8 bxor #xx:3,@aa:16 bxor #xx:3,@aa:32 bixor #xx:3,rd bixor #xx:3,@erd bixor #xx:3,@aa:8 bixor #xx:3,@aa:16 bixor #xx:3,@aa:32 c (#xx:3 of rd8) ? c c (#xx:3 of @erd) ? c c (#xx:3 of @aa:8) ? c c (#xx:3 of @aa:16) ? c c (#xx:3 of @aa:32) ? c c [a (#xx:3 of rd8)] ? c c [a (#xx:3 of @erd)] ? c c [a (#xx:3 of @aa:8)] ? c c [a (#xx:3 of @aa:16)] ? c c [a (#xx:3 of @aa:32)] ? c c (#xx:3 of rd8) ? c c (#xx:3 of @erd) ? c c (#xx:3 of @aa:8) ? c c (#xx:3 of @aa:16) ? c c (#xx:3 of @aa:32) ? c c [a (#xx:3 of rd8)] ? c c [a (#xx:3 of @erd)] ? c c [a (#xx:3 of @aa:8)] ? c c [a (#xx:3 of @aa:16)] ? c c [a (#xx:3 of @aa:32)] ? c c ? (#xx:3 of rd8) ? c c ? (#xx:3 of @erd) ? c c ? (#xx:3 of @aa:8) ? c c ? (#xx:3 of @aa:16) ? c c ? (#xx:3 of @aa:32) ? c c ? [a (#xx:3 of rd8)] ? c c ? [a (#xx:3 of @erd)] ? c c ? [a (#xx:3 of @aa:8)] ? c c ? [a (#xx:3 of @aa:16)] ? c c ? [a (#xx:3 of @aa:32)] ? c b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 4 6 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 1 3 3 4 5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
782 6. branch instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc bcc bra d:8(bt d:8) bra d:16(bt d:16) brn d:8(bf d:8) brn d:16(bf d:16) bhi d:8 bhi d:16 bls d:8 bls d:16 bcc d:8(bhs d:8) bcc d:16(bhs d:16) bcs d:8(blo d:8) bcs d:16(blo d:16) bne d:8 bne d:16 beq d:8 beq d:16 bvc d:8 bvc d:16 bvs d:8 bvs d:16 bpl d:8 bpl d:16 bmi d:8 bmi d:16 bge d:8 bge d:16 blt d:8 blt d:16 bgt d:8 bgt d:16 ble d:8 ble d:16 if condition is true then pc ? pc+d else next; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size always never c z=0 c z=1 c=0 c=1 z=0 z=1 v=0 v=1 n=0 n=1 n ? v=0 n ? v=1 z (n ? v)=0 z (n ? v)=1 branch condition
783 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc jmp bsr jsr rts jmp @ern jmp @aa:24 jmp @@aa:8 bsr d:8 bsr d:16 jsr @ern jsr @aa:24 jsr @@aa:8 rts pc ? ern pc ? aa:24 pc ? @aa:8 pc ? @-sp,pc ? pc+d:8 pc ? @-sp,pc ? pc+d:16 pc ? @-sp,pc ? ern pc ? @-sp,pc ? aa:24 pc ? @-sp,pc ? @aa:8 pc ? @sp+ ? ? ? ? ? ? ? ? ? 2 2 4 4 ? ? ? ? ? ? ? ? ? 2 3 2 4 2 2 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size 4 3 4 3 4 4 4 5 4 5 4 5 6 5
784 7. system control instructions mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc trapa rte sleep ldc trapa #xx:2 rte sleep ldc #xx:8,ccr ldc #xx:8,exr ldc rs,ccr ldc rs,exr ldc @ers,ccr ldc @ers,exr ldc @(d:16,ers),ccr ldc @(d:16,ers),exr ldc @(d:32,ers),ccr ldc @(d:32,ers),exr ldc @ers+,ccr ldc @ers+,exr ldc @aa:16,ccr ldc @aa:16,exr ldc @aa:32,ccr ldc @aa:32,exr pc ? @-sp,ccr ? @-sp, exr ? @-sp, ? pc exr ? @sp+,ccr ? @sp+, pc ? @sp+ transition to power-down state #xx:8 ? ccr #xx:8 ? exr rs8 ? ccr rs8 ? exr @ers ? ccr @ers ? exr @(d:16,ers) ? ccr @(d:16,ers) ? exr @(d:32,ers) ? ccr @(d:32,ers) ? exr @ers ? ccr,ers32+2 ? ers32 @ers ? exr,ers32+2 ? ers32 @aa:16 ? ccr @aa:16 ? exr @aa:32 ? ccr @aa:32 ? exr ? ? ? b b b b w w w w w w w w w w w w 2 4 2 2 4 4 6 6 10 10 4 4 6 6 8 8 1 ? ? ? ? ? ? ? ? ? 7 [9] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size 5 [9] 2 1 2 1 1 3 3 4 4 6 6 4 4 4 4 5 5 8 [9]
785 mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc stc andc orc xorc nop stc ccr,rd stc exr,rd stc ccr,@erd stc exr,@erd stc ccr,@(d:16,erd) stc exr,@(d:16,erd) stc ccr,@(d:32,erd) stc exr,@(d:32,erd) stc ccr,@-erd stc exr,@-erd stc ccr,@aa:16 stc exr,@aa:16 stc ccr,@aa:32 stc exr,@aa:32 andc #xx:8,ccr andc #xx:8,exr orc #xx:8,ccr orc #xx:8,exr xorc #xx:8,ccr xorc #xx:8,exr nop ccr ? rd8 exr ? rd8 ccr ? @erd exr ? @erd ccr ? @(d:16,erd) exr ? @(d:16,erd) ccr ? @(d:32,erd) exr ? @(d:32,erd) erd32-2 ? erd32,ccr ? @erd erd32-2 ? erd32,exr ? @erd ccr ? @aa:16 exr ? @aa:16 ccr ? @aa:32 exr ? @aa:32 ccr #xx:8 ? ccr exr #xx:8 ? exr ccr #xx:8 ? ccr exr #xx:8 ? exr ccr ? #xx:8 ? ccr exr ? #xx:8 ? exr pc ? pc+2 b b w w w w w w w w w w w w b b b b b b ? 2 4 2 4 2 4 2 2 4 4 6 6 10 10 4 4 6 6 8 8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 1 3 3 4 4 6 6 4 4 4 4 5 5 1 2 1 2 1 2 1 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? operation condition code no. of states * 1 normal advanced size
786 8. block transfer instruction mnemonic addressing mode and instruction length (bytes) #xx rn @ern @(d,ern) @-ern/@ern+ @aa @(d,pc) @@aa ihnzvc eepmov eepmov.b eepmov.w if r4l 1 0 repeat @er5 ? @er6 er5+1 ? er5 er6+1 ? er6 r4l-1 ? r4l until r4l=0 else next; if r4 1 0 repeat @er5 ? @er6 er5+1 ? er5 er6+1 ? er6 r4-1 ? r4 until r4=0 else next; ? ? ? ? 4+2n * 3 4+2n * 3 4 4 operation condition code no. of states * 1 normal advanced size notes: 1. the number of states is the number of states required for execution when the instruction and its operands are located in on-chip memory. 2. only register er0, er1, er4, or er5 should be used when using the tas instruction. 3. n is the initial value set in r4l or r4. 4. only registers er0 to er6 should be used when using the stm/ldm instruction. [1] 7 states when the number of saved/restored registers is 2, 9 states when 3, and 11 states when 4. [2] cannot be used with the lsi. [3] set to 1 when there is a carry from or borrow to bit 11; otherwise cleared to 0. [4] set to 1 when there is a carry from or borrow to bit 27; otherwise cleared to 0. [5] if the result is zero, the previous value of the flag is retained; otherwise the flag is cleared to 0. [6] set to 1 if the divisor is negative; otherwise cleared to 0. [7] set to 1 if the divisor is zero; otherwise cleared to 0. [8] set to 1 if the quotient is negative; otherwise cleared to 0. [9] when exr is valid, the number of states is increased by 1.
787 a.2 instruction codes table a.2 instruction codes add.b #xx:8,rd add.b rs,rd add.w #xx:16,rd add.w rs,rd add.l #xx:32,erd add.l ers,erd adds #1,erd adds #2,erd adds #4,erd addx #xx:8,rd addx rs,rd and.b #xx:8,rd and.b rs,rd and.w #xx:16,rd and.w rs,rd and.l #xx:32,erd and.l ers,erd andc #xx:8,ccr andc #xx:8,exr band #xx:3,rd band #xx:3,@erd band #xx:3,@aa:8 band #xx:3,@aa:16 band #xx:3,@aa:32 bra d:8 (bt d:8) bra d:16 (bt d:16) brn d:8 (bf d:8) brn d:16 (bf d:16) mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion add adds addx and andc band bcc b b w w l l l l l b b b b w w l l b b b b b b b 1 0 0 ers imm erd 0 0 0 0 0 0 erd erd erd erd erd erd ers imm imm 0 erd 0 imm 0 imm 0 0 0 8 0 7 0 7 0 0 0 0 9 0 e 1 7 6 7 0 0 0 7 7 7 6 6 4 5 4 5 rd 8 9 9 a a b b b rd e rd 6 9 6 a 1 6 1 6 c e a a 0 8 1 8 rd rd rd rd rd rd rd 0 1 rd 0 0 0 0 0 6 0 7 7 6 6 6 6 0 0 76 0 76 0 imm imm imm imm abs disp disp rs 1 rs 1 0 8 9 rs rs 6 rs 6 f 4 1 3 0 1 imm imm abs disp disp imm imm abs imm
788 bhi d:8 bhi d:16 bls d:8 bls d:16 bcc d:8 (bhs d:8) bcc d:16 (bhs d:16) bcs d:8 (blo d:8) bcs d:16 (blo d:16) bne d:8 bne d:16 beq d:8 beq d:16 bvc d:8 bvc d:16 bvs d:8 bvs d:16 bpl d:8 bpl d:16 bmi d:8 bmi d:16 bge d:8 bge d:16 blt d:8 blt d:16 bgt d:8 bgt d:16 ble d:8 ble d:16 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bcc 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 8 a 8 b 8 c 8 d 8 e 8 f 8 2 3 4 5 6 7 8 9 a b c d e f disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp 0 0 0 0 0 0 0 0 0 0 0 0 0 0
789 bclr #xx:3,rd bclr #xx:3,@erd bclr #xx:3,@aa:8 bclr #xx:3,@aa:16 bclr #xx:3,@aa:32 bclr rn,rd bclr rn,@erd bclr rn,@aa:8 bclr rn,@aa:16 bclr rn,@aa:32 biand #xx:3,rd biand #xx:3,@erd biand #xx:3,@aa:8 biand #xx:3,@aa:16 biand #xx:3,@aa:32 bild #xx:3,rd bild #xx:3,@erd bild #xx:3,@aa:8 bild #xx:3,@aa:16 bild #xx:3,@aa:32 bior #xx:3,rd bior #xx:3,@erd bior #xx:3,@aa:8 bior #xx:3,@aa:16 bior #xx:3,@aa:32 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bclr biand bild bior b b b b b b b b b b b b b b b b b b b b b b b b b 0 0 0 1 0 1 0 1 0 imm erd erd imm erd imm erd imm erd 0 1 1 1 imm imm imm imm 0 1 1 1 imm imm imm imm 7 7 7 6 6 6 7 7 6 6 7 7 7 6 6 7 7 7 6 6 7 7 7 6 6 2 d f a a 2 d f a a 6 c e a a 7 c e a a 4 c e a a 1 3 rn 1 3 1 3 1 3 1 3 rd 0 8 8 rd 0 8 8 rd 0 0 0 rd 0 0 0 rd 0 0 0 7 7 6 6 7 7 7 7 7 7 2 2 2 2 6 6 7 7 4 4 rn rn 0 0 0 0 0 0 0 0 0 0 7 6 7 7 7 2 2 6 7 4 rn 0 0 0 0 0 7 6 7 7 7 2 2 6 7 4 rn 0 0 0 0 0 abs abs abs abs abs abs abs abs abs abs abs abs abs abs abs 0 0 1 1 1 1 1 1 imm imm imm imm imm imm imm imm
790 bist #xx:3,rd bist #xx:3,@erd bist #xx:3,@aa:8 bist #xx:3,@aa:16 bist #xx:3,@aa:32 bixor #xx:3,rd bixor #xx:3,@erd bixor #xx:3,@aa:8 bixor #xx:3,@aa:16 bixor #xx:3,@aa:32 bld #xx:3,rd bld #xx:3,@erd bld #xx:3,@aa:8 bld #xx:3,@aa:16 bld #xx:3,@aa:32 bnot #xx:3,rd bnot #xx:3,@erd bnot #xx:3,@aa:8 bnot #xx:3,@aa:16 bnot #xx:3,@aa:32 bnot rn,rd bnot rn,@erd bnot rn,@aa:8 bnot rn,@aa:16 bnot rn,@aa:32 mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bist bixor bld bnot b b b b b b b b b b b b b b b b b b b b b b b b b 1 0 1 0 0 0 0 0 0 imm erd imm erd imm erd imm erd erd imm imm imm imm imm imm imm imm 1 1 0 0 imm imm imm imm 1 1 0 0 imm imm imm imm 1 1 1 1 0 0 0 0 6 7 7 6 6 7 7 7 6 6 7 7 7 6 6 7 7 7 6 6 6 7 7 6 6 7 d f a a 5 c e a a 7 c e a a 1 d f a a 1 d f a a 1 3 1 3 1 3 1 3 rn 1 3 rd 0 8 8 rd 0 0 0 rd 0 0 0 rd 0 8 8 rd 0 8 8 6 6 7 7 7 7 7 7 6 6 7 7 5 5 7 7 1 1 1 1 rn rn 0 0 0 0 0 0 0 0 0 0 6 7 7 7 6 7 5 7 1 1rn 0 0 0 0 0 6 7 7 7 6 7 5 7 1 1rn 0 0 0 0 0 abs abs abs abs abs abs abs abs abs abs abs abs abs abs abs
791 bor #xx:3,rd bor #xx:3,@erd bor #xx:3,@aa:8 bor #xx:3,@aa:16 bor #xx:3,@aa:32 bset #xx:3,rd bset #xx:3,@erd bset #xx:3,@aa:8 bset #xx:3,@aa:16 bset #xx:3,@aa:32 bset rn,rd bset rn,@erd bset rn,@aa:8 bset rn,@aa:16 bset rn,@aa:32 bsr d:8 bsr d:16 bst #xx:3,rd bst #xx:3,@erd bst #xx:3,@aa:8 bst #xx:3,@aa:16 bst #xx:3,@aa:32 btst #xx:3,rd btst #xx:3,@erd btst #xx:3,@aa:8 btst #xx:3,@aa:16 btst #xx:3,@aa:32 btst rn,rd btst rn,@erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion bor bset bsr bst btst b b b b b b b b b b b b b b b b b b b b b b b b b b b 0 0 0 0 0 0 0 0 0 0 imm erd imm erd erd imm erd imm erd erd abs abs abs disp abs abs imm imm imm imm imm imm imm imm 0 0 0 0 imm imm imm imm 0 0 0 0 imm imm imm imm 0 0 0 0 0 0 0 0 7 7 7 6 6 7 7 7 6 6 6 7 7 6 6 5 5 6 7 7 6 6 7 7 7 6 6 6 7 4 c e a a 0 d f a a 0 d f a a 5 c 7 d f a a 3 c e a a 3 c 1 3 1 3 rn 1 3 0 1 3 1 3 rn rd 0 0 0 rd 0 8 8 rd 0 8 8 0 rd 0 8 8 rd 0 0 0 rd 0 7 7 7 7 6 6 6 6 7 7 6 4 4 0 0 0 0 7 7 3 3 3 rn rn rn 0 0 0 0 0 0 0 0 0 0 0 7 7 6 6 7 4 0 0 7 3 rn 0 0 0 0 0 7 7 6 6 7 4 0 0 7 3 rn 0 0 0 0 0 abs abs abs disp abs abs abs abs abs abs abs
792 btst rn,@aa:8 btst rn,@aa:16 btst rn,@aa:32 bxor #xx:3,rd bxor #xx:3,@erd bxor #xx:3,@aa:8 bxor #xx:3,@aa:16 bxor #xx:3,@aa:32 clrmac cmp.b #xx:8,rd cmp.b rs,rd cmp.w #xx:16,rd cmp.w rs,rd cmp.l #xx:32,erd cmp.l ers,erd daa rd das rd dec.b rd dec.w #1,rd dec.w #2,rd dec.l #1,erd dec.l #2,erd divxs.b rs,rd divxs.w rs,erd divxu.b rs,rd divxu.w rs,erd eepmov.b eepmov.w mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion btst bxor clrmac cmp daa das dec divxs divxu eepmov b b b b b b b b b b w w l l b b b w w l l b w b w 0 0 1 imm erd ers 0 0 0 0 0 erd erd erd erd erd imm imm 0 erd 0 imm 0 imm 0 0 7 6 6 7 7 7 6 6 a 1 7 1 7 1 0 1 1 1 1 1 1 0 0 5 5 7 7 e a a 5 c e a a rd c 9 d a f f f a b b b b 1 1 1 3 b b 1 3 1 3 rs 2 rs 2 0 0 0 5 d 7 f d d rs rs 5 d 0 0 rd 0 0 0 rd rd rd rd rd rd rd rd 0 0 rd c 4 6 7 7 5 5 5 5 3 5 5 1 3 9 9 rn rs rs 8 8 0 0 0 rd f f 6 7 3 5 rn 0 0 6 7 3 5 rn 0 0 abs abs imm abs abs imm abs abs imm cannot be used with the lsi.
793 exts.w rd exts.l erd extu.w rd extu.l erd inc.b rd inc.w #1,rd inc.w #2,rd inc.l #1,erd inc.l #2,erd jmp @ern jmp @aa:24 jmp @@aa:8 jsr @ern jsr @aa:24 jsr @@aa:8 ldc #xx:8,ccr ldc #xx:8,exr ldc rs,ccr ldc rs,exr ldc @ers,ccr ldc @ers,exr ldc @(d:16,ers),ccr ldc @(d:16,ers),exr ldc @(d:32,ers),ccr ldc @(d:32,ers),exr ldc @ers+,ccr ldc @ers+,exr ldc @aa:16,ccr ldc @aa:16,exr mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion exts extu inc jmp jsr ldc w l w l b w w l l b b b b w w w w w w w w w w 0 0 ern ern 0 0 0 0 erd erd erd erd ers ers ers ers ers ers ers ers 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 5 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 a b b b b 9 a b d e f 7 1 3 3 1 1 1 1 1 1 1 1 1 1 d f 5 7 0 5 d 7 f 4 0 1 4 4 4 4 4 4 4 4 4 4 rd rd rd rd rd 0 0 1 rs rs 0 1 0 1 0 1 0 1 0 1 0 6 6 6 6 7 7 6 6 6 6 7 9 9 f f 8 8 d d b b 0 0 0 0 0 0 0 0 0 0 0 0 6 6 b b 2 2 0 0 abs abs abs abs imm imm disp disp disp disp disp disp
794 0 0 rd abs rs rd ldc @aa:32,ccr ldc @aa:32,exr ldm.l @sp+, (ern-ern+1) ldm.l @sp+, (ern-ern+2) ldm.l @sp+, (ern-ern+3) ldmac ers,mach ldmac ers,macl mac @ern+,@erm+ mov.b #xx:8,rd mov.b rs,rd mov.b @ers,rd mov.b @(d:16,ers),rd mov.b @(d:32,ers),rd mov.b @ers+,rd mov.b @aa:8,rd mov.b @aa:16,rd mov.b @aa:32,rd mov.b rs,@erd mov.b rs,@(d:16,erd) mov.b rs,@(d:32,erd) mov.b rs,@-erd mov.b rs,@aa:8 mov.b rs,@aa:16 mov.b rs,@aa:32 mov.w #xx:16,rd mov.w rs,rd mov.w @ers,rd mov.w @(d:16,ers),rd mov.w @(d:32,ers),rd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion ldc ldm * 3 ldmac mac mov w w l l l l l b b b b b b b b b b b b b b b b w w w w w 0 0 0 0 1 1 0 1 0 0 0 ers ers ers ers erd erd erd erd ers ers ers 0 0 0 ern+1 ern+2 ern+3 0 0 0 0 0 f 0 6 6 7 6 2 6 6 6 6 7 6 3 6 6 7 0 6 6 7 1 1 1 1 1 rd c 8 e 8 c rd a a 8 e 8 c rs a a 9 d 9 f 8 4 4 1 2 3 rs 0 2 8 a 0 rs 0 1 0 0 0 rd rd rd 0 rd rd rd rs rs 0 rs rs rs rd rd rd rd 0 6 6 6 6 6 6 6 6 b b d d d a a b 2 2 7 7 7 2 a 2 imm abs abs disp abs disp abs imm disp abs abs abs abs disp disp disp cannot be used with the lsi.
795 mov.w @ers+,rd mov.w @aa:16,rd mov.w @aa:32,rd mov.w rs,@erd mov.w rs,@(d:16,erd) mov.w rs,@(d:32,erd) mov.w rs,@-erd mov.w rs,@aa:16 mov.w rs,@aa:32 mov.l #xx:32,rd mov.l ers,erd mov.l @ers,erd mov.l @(d:16,ers),erd mov.l @(d:32,ers),erd mov.l @ers+,erd mov.l @aa:16 ,erd mov.l @aa:32 ,erd mov.l ers,@erd mov.l ers,@(d:16,erd) mov.l ers,@(d:32,erd) * 1 mov.l ers,@-erd mov.l ers,@aa:16 mov.l ers,@aa:32 movfpe @aa:16,rd movtpe rs,@aa:16 mulxs.b rs,rd mulxs.w rs,erd mulxu.b rs,rd mulxu.w rs,erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion mov movfpe movtpe mulxs mulxu w w w w w w w w w l l l l l l l l l l l l l l b b b w b w 0 1 1 0 1 1 ers erd erd erd erd ers 0 0 0 erd erd erd ers ers ers ers erd erd erd erd 0 0 0 0 0 0 0 0 0 0 0 erd erd erd erd erd ers ers ers ers ers erd 0 0 erd ers 0 0 0 0 1 1 0 1 6 6 6 6 6 7 6 6 6 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 d b b 9 f 8 d b b a f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 2 8 a 0 0 0 0 0 0 0 0 0 0 0 0 0 c c rs rs rd rd rd rs rs 0 rs rs rs 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rd 6 6 6 7 6 6 6 6 6 7 6 6 6 5 5 b 9 f 8 d b b 9 f 8 d b b 0 2 a 0 2 8 a rs rs rs 0 0 rd 6 6 b b 2 a abs disp abs abs abs imm disp abs disp abs disp abs abs disp disp cannot be used with the lsi.
796 neg.b rd neg.w rd neg.l erd nop not.b rd not.w rd not.l erd or.b #xx:8,rd or.b rs,rd or.w #xx:16,rd or.w rs,rd or.l #xx:32,erd or.l ers,erd orc #xx:8,ccr orc #xx:8,exr pop.w rn pop.l ern push.w rn push.l ern rotl.b rd rotl.b #2, rd rotl.w rd rotl.w #2, rd rotl.l erd rotl.l #2, erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion neg nop not or orc pop push rotl b w l b w l b b w w l l b b w l w l b b w w l l 0 0 0 0 0 erd erd erd erd erd 1 1 1 0 1 1 1 c 1 7 6 7 0 0 0 6 0 6 0 1 1 1 1 1 1 7 7 7 0 7 7 7 rd 4 9 4 a 1 4 1 d 1 d 1 2 2 2 2 2 2 8 9 b 0 0 1 3 rs 4 rs 4 f 4 7 0 f 0 8 c 9 d b f rd rd 0 rd rd rd rd rd 0 1 rn 0 rn 0 rd rd rd rd imm imm 6 0 6 6 4 4 d d ers 0 0 0 erd ern ern 0 7 f imm imm imm
797 rotr.b rd rotr.b #2, rd rotr.w rd rotr.w #2, rd rotr.l erd rotr.l #2, erd rotxl.b rd rotxl.b #2, rd rotxl.w rd rotxl.w #2, rd rotxl.l erd rotxl.l #2, erd rotxr.b rd rotxr.b #2, rd rotxr.w rd rotxr.w #2, rd rotxr.l erd rotxr.l #2, erd rte rts shal.b rd shal.b #2, rd shal.w rd shal.w #2, rd shal.l erd shal.l #2, erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion rotr rotxl rotxr rte rts shal b b w w l l b b w w l l b b w w l l b b w w l l 0 0 0 0 0 0 0 0 erd erd erd erd erd erd erd erd 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 1 1 1 1 3 3 3 3 3 3 2 2 2 2 2 2 3 3 3 3 3 3 6 4 0 0 0 0 0 0 8 c 9 d b f 0 4 1 5 3 7 0 4 1 5 3 7 7 7 8 c 9 d b f rd rd rd rd rd rd rd rd rd rd rd rd 0 0 rd rd rd rd
798 shar.b rd shar.b #2, rd shar.w rd shar.w #2, rd shar.l erd shar.l #2, erd shll.b rd shll.b #2, rd shll.w rd shll.w #2, rd shll.l erd shll.l #2, erd shlr.b rd shlr.b #2, rd shlr.w rd shlr.w #2, rd shlr.l erd shlr.l #2, erd sleep stc.b ccr,rd stc.b exr,rd stc.w ccr,@erd stc.w exr,@erd stc.w ccr,@(d:16,erd) stc.w exr,@(d:16,erd) stc.w ccr,@(d:32,erd) stc.w exr,@(d:32,erd) stc.w ccr,@-erd stc.w exr,@-erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion shar shll shlr sleep stc b b w w l l b b w w l l b b w w l l b b w w w w w w w w 0 0 0 0 0 0 erd erd erd erd erd erd 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 8 c 9 d b f 0 4 1 5 3 7 0 4 1 5 3 7 8 0 1 4 4 4 4 4 4 4 4 rd rd rd rd rd rd rd rd rd rd rd rd 0 rd rd 0 1 0 1 0 1 0 1 erd erd erd erd erd erd erd erd 1 1 1 1 0 0 1 1 6 6 6 6 7 7 6 6 9 9 f f 8 8 d d 0 0 0 0 0 0 0 0 6 6 b b a a 0 0 disp disp disp disp
799 stc.w ccr,@aa:16 stc.w exr,@aa:16 stc.w ccr,@aa:32 stc.w exr,@aa:32 stm.l (ern-ern+1), @-sp stm.l (ern-ern+2), @-sp stm.l (ern-ern+3), @-sp stmac mach,erd stmac macl,erd sub.b rs,rd sub.w #xx:16,rd sub.w rs,rd sub.l #xx:32,erd sub.l ers,erd subs #1,erd subs #2,erd subs #4,erd subx #xx:8,rd subx rs,rd tas @erd * 2 trapa #x:2 xor.b #xx:8,rd xor.b rs,rd xor.w #xx:16,rd xor.w rs,rd xor.l #xx:32,erd xor.l ers,erd mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion stc stm * 3 stmac sub subs subx tas trapa xor w w w w l l l l l b w w l l l l l b b b b b w w l l 1 00 ers imm 0 0 0 0 0 0 erd erd erd erd erd erd erd ers 0 0 0 0 ern ern ern erd 0 0 0 0 0 0 0 0 0 1 7 1 7 1 1 1 1 b 1 0 5 d 1 7 6 7 0 1 1 1 1 1 1 1 8 9 9 a a b b b rd e 1 7 rd 5 9 5 a 1 4 4 4 4 1 2 3 rs 3 rs 3 0 8 9 rs e rs 5 rs 5 f 0 1 0 1 0 0 0 rd rd rd rd 0 0 rd rd rd 0 6 6 6 6 6 6 6 7 6 b b b b d d d b 5 8 8 a a f f f 0 0 0 0 c abs abs abs abs imm imm imm imm imm imm cannot be used with the lsi.
800 xorc #xx:8,ccr xorc #xx:8,exr mnemonic size instruction format 1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte 8th byte 9th byte 10th byte instruc- tion xorc b b 0 0 5 1 4 1 0 5 imm imm notes: bit 7 of the 4th byte of the mov.l ers, @ (d:32, erd) instruction can be either 0 or 1. only register er0, er1, er4, or er5 should be used when using the tas instruction. only registers er0 to er6 should be used when using the stm/ldm instruction. legend address registers 32-bit registers register field general register register field general register register field general register 000 001 111 er0 er1 er7 0000 0001 0111 1000 1001 1111 r0 r1 r7 e0 e1 e7 0000 0001 0111 1000 1001 1111 r0h r1h r7h r0l r1l r7l 16-bit register 8-bit register imm: abs: disp: rs, rd, rn: ers, erd, ern, erm: the correspondence between register fields and general registers is shown in the following table. immediate data (2, 3, 8, 16, or 32 bits) absolute address (8, 16, 24, or 32 bits) displacement (8, 16, or 32 bits) register field (4 bits, indicating an 8-bit or 16-bit register. rs, rd, and rn correspond to operand formats rs, rd, and rn, re spectively.) register field (3 bits, indicating an address register or 32-bit register. ers, erd, ern, and erm correspond to operand formats ers, erd, ern, and erm, respectively.) 1. 2. 3.
801 a.3 operation code map table a.3 shows the operation code map. table a.3 operation code map (1) instruction code: 1st byte 2nd byte ah al bh bl instruction when most significant bit of bh is 0. instruction when most significant bit of bh is 1. 0 nop bra mulxu bset ah al 0 1 2 3 4 5 6 7 8 9 a b c d e f 1 brn divxu bnot 2 bhi mulxu bclr 3 bls divxu btst stc stmac ldc ldmac 4 orc or bcc rts or bor bior 6 andc and bne rte and 5 xorc xor bcs bsr xor bxor bixor band biand 7 ldc beq trapa bst bist bld bild 8 bvc mov 9 bvs a bpl jmp b bmi eepmov c bge bsr d blt mov e addx subx bgt jsr f ble mov.b add addx cmp subx or xor and mov add sub mov mov cmp table a.3 (3) ** note: * cannot be used with the lsi. table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2) table a.3 (2)
802 table a.3 operation code map (2) instruction code: 1st byte 2nd byte ah al bh bl 01 0a 0b 0f 10 11 12 13 17 1a 1b 1f 58 6a 79 7a 0 mov inc adds daa dec subs das bra mov mov mov shll shlr rotxl rotxr not 1 ldm brn add add 2 bhi mov cmp cmp 3 stm not bls sub sub 4 shll shlr rotxl rotxr bcc movfpe or or 5 inc extu dec bcs xor xor 6 mac bne and and 7 inc shll shlr rotxl rotxr extu dec beq ldc stc 8 sleep bvc mov adds shal shar rotl rotr neg subs 9 bvs a clrmac bpl mov b neg bmi add mov sub cmp c shal shar rotl rotr bge movtpe d inc exts dec blt e tas bgt f inc shal shar rotl rotr exts dec ble bh ah al * * note: * cannot be used with the lsi. * * table a.3 (4) table a.3 (4) table a.3 (3) table a.3 (3) table a.3 (3)
803 table a.3 operation code map (3) instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl instruction when most significant bit of dh is 0. instruction when most significant bit of dh is 1. notes: 1. r is the register specification field. 2. aa is the absolute address specification. ah al bh bl ch cl 01c05 01d05 01f06 7cr06 * 1 7cr07 * 1 7dr06 * 1 7dr07 * 1 7eaa6 * 2 7eaa7 * 2 7faa6 * 2 7faa7 * 2 0 mulxs bset bset bset bset 1 divxs bnot bnot bnot bnot 2 mulxs bclr bclr bclr bclr 3 divxs btst btst btst btst 4 or 5 xor 6 and 789abcdef bor bior bxor bixor band biand bld bild bst bist bor bior bxor bixor band biand bld bild bst bist
804 table a.3 operation code map (4) instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl instruction when most significant bit of fh is 0. instruction when most significant bit of fh is 1. 5th byte 6th byte eh el fh fl instruction code: 1st byte 2nd byte ah al bh bl 3rd byte 4th byte ch cl dh dl indicates case where msb of hh is 0. indicates case where msb of hh is 1. note: * aa is the absolute address specification. 5th byte 6th byte eh el fh fl 7th byte 8th byte gh gl hh hl 6a10aaaa6 * 6a10aaaa7 * 6a18aaaa6 * 6a18aaaa7 * ahalbhblchcldhdleh el 0 bset 1 bnot 2 bclr 3 btst bor bior bxor bixor band biand bld bild bst bist 456789abcdef 6a30aaaaaaaa6 * 6a30aaaaaaaa7 * 6a38aaaaaaaa6 * 6a38aaaaaaaa7 * ahalbhbl ... fhflgh gl 0 bset 1 bnot 2 bclr 3 btst bor bior bxor bixor band biand bld bild bst bist 456789abcdef
805 a.4 number of states required for execution the tables in this section can be used to calculate the number of states required for instruction execution by the h8s/2000 cpu. table a.5 shows the number of instruction fetch, data read/write, and other cycles occurring in each instruction, and table a.4 shows the number of states required per cycle according to the bus size. the number of states required for execution of an instruction can be calculated from these two tables as follows: number of states = i s i + j s j + k s k + l s l + m s m + n s n examples of calculation of number of states required for execution examples: advanced mode, stack located in external address space, on-chip supporting modules accessed in two states with 8-bit bus width, external devices accessed in three states with one wait state and 16-bit bus width. 1. bset #0,@ffffc7:8 from table a.5, i = l = 2 and j = k = m = n = 0 from table a.4, s i = 4 and s l = 2 number of states = 2 4 + 2 2 = 12 2. jsr @@30 from table a.5, i = j = k = 2 and l = m = n = 0 from table a.4, s i = s j = s k = 4 number of states = 2 4 + 2 4 + 2 4 = 24
806 table a.4 number of states per cycle access conditions on-chip external device supporting module 8-bit bus 16-bit bus cycle on-chip memory 8-bit bus 16-bit bus 2-state access 3-state access 2-state access 3-state access instruction fetch s i 1 4 2 4 6 + 2m 2 3 + m branch address fetch s j stack operation s k byte data access s l 2 2 3 + m word data access s m 4 4 6 + 2m internal operation s n 1111111 legend: m: number of wait states inserted into external device access
807 table a.5 number of cycles per instruction instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n add add.b #xx:8,rd 1 add.b rs,rd 1 add.w #xx:16,rd 2 add.w rs,rd 1 add.l #xx:32,erd 3 add.l ers,erd 1 adds adds #1/2/4,erd 1 addx addx #xx:8,rd 1 addx rs,rd 1 and and.b #xx:8,rd 1 and.b rs,rd 1 and.w #xx:16,rd 2 and.w rs,rd 1 and.l #xx:32,erd 3 and.l ers,erd 2 andc andc #xx:8,ccr 1 andc #xx:8,exr 2 band band #xx:3,rd 1 band #xx:3,@erd 2 1 band #xx:3,@aa:8 2 1 band #xx:3,@aa:16 3 1 band #xx:3,@aa:32 4 1 bcc bra d:8 (bt d:8) 2 brn d:8 (bf d:8) 2 bhi d:8 2 bls d:8 2 bcc d:8 (bhs d:8) 2 bcs d:8 (blo d:8) 2 bne d:8 2 beq d:8 2 bvc d:8 2 bvs d:8 2 bpl d:8 2 bmi d:8 2 bge d:8 2 blt d:8 2
808 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bcc bgt d:8 2 ble d:8 2 bra d:16 (bt d:16) 2 1 brn d:16 (bf d:16) 2 1 bhi d:16 2 1 bls d:16 2 1 bcc d:16 (bhs d:16) 2 1 bcs d:16 (blo d:16) 2 1 bne d:16 2 1 beq d:16 2 1 bvc d:16 2 1 bvs d:16 2 1 bpl d:16 2 1 bmi d:16 2 1 bge d:16 2 1 blt d:16 2 1 bgt d:16 2 1 ble d:16 2 1 bclr bclr #xx:3,rd 1 bclr #xx:3,@erd 2 2 bclr #xx:3,@aa:8 2 2 bclr #xx:3,@aa:16 3 2 bclr #xx:3,@aa:32 4 2 bclr rn,rd 1 bclr rn,@erd 2 2 bclr rn,@aa:8 2 2 bclr rn,@aa:16 3 2 bclr rn,@aa:32 4 2 biand biand #xx:3,rd 1 biand #xx:3,@erd 2 1 biand #xx:3,@aa:8 2 1 biand #xx:3,@aa:16 3 1 biand #xx:3,@aa:32 4 1
809 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bild bild #xx:3,rd 1 bild #xx:3,@erd 2 1 bild #xx:3,@aa:8 2 1 bild #xx:3,@aa:16 3 1 bild #xx:3,@aa:32 4 1 bior bior #xx:8,rd 1 bior #xx:8,@erd 2 1 bior #xx:8,@aa:8 2 1 bior #xx:8,@aa:16 3 1 bior #xx:8,@aa:32 4 1 bist bist #xx:3,rd 1 bist #xx:3,@erd 2 2 bist #xx:3,@aa:8 2 2 bist #xx:3,@aa:16 3 2 bist #xx:3,@aa:32 4 2 bixor bixor #xx:3,rd 1 bixor #xx:3,@erd 2 1 bixor #xx:3,@aa:8 2 1 bixor #xx:3,@aa:16 3 1 bixor #xx:3,@aa:32 4 1 bld bld #xx:3,rd 1 bld #xx:3,@erd 2 1 bld #xx:3,@aa:8 2 1 bld #xx:3,@aa:16 3 1 bld #xx:3,@aa:32 4 1 bnot bnot #xx:3,rd 1 bnot #xx:3,@erd 2 2 bnot #xx:3,@aa:8 2 2 bnot #xx:3,@aa:16 3 2 bnot #xx:3,@aa:32 4 2 bnot rn,rd 1 bnot rn,@erd 2 2 bnot rn,@aa:8 2 2 bnot rn,@aa:16 3 2 bnot rn,@aa:32 4 2
810 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bor bor #xx:3,rd 1 bor #xx:3,@erd 2 1 bor #xx:3,@aa:8 2 1 bor #xx:3,@aa:16 3 1 bor #xx:3,@aa:32 4 1 bset bset #xx:3,rd 1 bset #xx:3,@erd 2 2 bset #xx:3,@aa:8 2 2 bset #xx:3,@aa:16 3 2 bset #xx:3,@aa:32 4 2 bset rn,rd 1 bset rn,@erd 2 2 bset rn,@aa:8 2 2 bset rn,@aa:16 3 2 bset rn,@aa:32 4 2 bsr bsr d:8 normal 2 1 advanced 2 2 bsr d:16 normal 2 1 1 advanced 2 2 1 bst bst #xx:3,rd 1 bst #xx:3,@erd 2 2 bst #xx:3,@aa:8 2 2 bst #xx:3,@aa:16 3 2 bst #xx:3,@aa:32 4 2 btst btst #xx:3,rd 1 btst #xx:3,@erd 2 1 btst #xx:3,@aa:8 2 1 btst #xx:3,@aa:16 3 1 btst #xx:3,@aa:32 4 1 btst rn,rd 1 btst rn,@erd 2 1 btst rn,@aa:8 2 1 btst rn,@aa:16 3 1 btst rn,@aa:32 4 1
811 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n bxor bxor #xx:3,rd 1 bxor #xx:3,@erd 2 1 bxor #xx:3,@aa:8 2 1 bxor #xx:3,@aa:16 3 1 bxor #xx:3,@aa:32 4 1 clrmac clrmac cannot be used with the lsi. cmp cmp.b #xx:8,rd 1 cmp.b rs,rd 1 cmp.w #xx:16,rd 2 cmp.w rs,rd 1 cmp.l #xx:32,erd 3 cmp.l ers,erd 1 daa daa rd 1 das das rd 1 dec dec.b rd 1 dec.w #1/2,rd 1 dec.l #1/2,erd 1 divxs divxs.b rs,rd 2 11 divxs.w rs,erd 2 19 divxu divxu.b rs,rd 1 11 divxu.w rs,erd 1 19 eepmov eepmov.b 2 2n+2 * 2 eepmov.w 2 2n+2 * 2 exts exts.w rd 1 exts.l erd 1 extu extu.w rd 1 extu.l erd 1 inc inc.b rd 1 inc.w #1/2,rd 1 inc.l #1/2,erd 1 jmp jmp @ern 2 jmp @aa:24 2 1 jmp @@aa:8 normal 2 1 1 advanced 2 2 1
812 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n jsr jsr @ern normal 2 1 advanced 2 2 jsr @aa:24 normal 2 1 1 advanced 2 2 1 jsr @@aa:8 normal 2 1 1 advanced 2 2 2 ldc ldc #xx:8,ccr 1 ldc #xx:8,exr 2 ldc rs,ccr 1 ldc rs,exr 1 ldc @ers,ccr 2 1 ldc @ers,exr 2 1 ldc @(d:16,ers),ccr 3 1 ldc @(d:16,ers),exr 3 1 ldc @(d:32,ers),ccr 5 1 ldc @(d:32,ers),exr 5 1 ldc @ers+,ccr 2 1 1 ldc @ers+,exr 2 1 1 ldc @aa:16,ccr 3 1 ldc @aa:16,exr 3 1 ldc @aa:32,ccr 4 1 ldc @aa:32,exr 4 1 ldm * 4 l dm . l @s p+, (ern-ern+1) 2 4 1 l dm . l @s p+, (ern-ern+2) 2 6 1 l dm . l @s p+, (ern-ern+3) 2 8 1 ldmac ldmac ers, mach cannot be used with the lsi. ldmac ers, macl mac mac @ern+, @erm+ mov mov.b #xx:8,rd 1 mov.b rs,rd 1 mov.b @ers,rd 1 1 mov.b @(d:16,ers),rd 2 1 mov.b @(d:32,ers),rd 4 1 mov.b @ers+,rd 1 1 1 mov.b @aa:8,rd 1 1 mov.b @aa:16,rd 2 1
813 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n mov mov.b @aa:32,rd 3 1 mov.b rs,@erd 1 1 mov.b rs,@(d:16,erd) 2 1 mov.b rs,@(d:32,erd) 4 1 mov.b rs,@-erd 1 1 1 mov.b rs,@aa:8 1 1 mov.b rs,@aa:16 2 1 mov.b rs,@aa:32 3 1 mov.w #xx:16,rd 2 mov.w rs,rd 1 mov.w @ers,rd 1 1 mov.w @(d:16,ers),rd 2 1 mov.w @(d:32,ers),rd 4 1 mov.w @ers+,rd 1 1 1 mov.w @aa:16,rd 2 1 mov.w @aa:32,rd 3 1 mov.w rs,@erd 1 1 mov.w rs,@(d:16,erd) 2 1 mov.w rs,@(d:32,erd) 4 1 mov.w rs,@-erd 1 1 1 mov.w rs,@aa:16 2 1 mov.w rs,@aa:32 3 1 mov.l #xx:32,erd 3 mov.l ers,erd 1 mov.l @ers,erd 2 2 mov.l @(d:16,ers),erd 3 2 mov.l @(d:32,ers),erd 5 2 mov.l @ers+,erd 2 2 1 mov.l @aa:16,erd 3 2 mov.l @aa:32,erd 4 2 mov.l ers,@erd 2 2 mov.l ers,@(d:16,erd) 3 2 mov.l ers,@(d:32,erd) 5 2 mov.l ers,@-erd 2 2 1 mov.l ers,@aa:16 3 2 mov.l ers,@aa:32 4 2
814 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n movfpe movfpe @:aa:16,rd cannot be used with the lsi. movtpe movtpe rs,@:aa:16 mulxs mulxs.b rs,rd 2 11 mulxs.w rs,erd 2 19 mulxu mulxu.b rs,rd 1 11 mulxu.w rs,erd 1 19 neg neg.b rd 1 neg.w rd 1 neg.l erd 1 nop nop 1 not not.b rd 1 not.w rd 1 not.l erd 1 or or .b #xx:8,rd 1 or .b rs,rd 1 or .w #xx:16,rd 2 or.w rs,rd 1 or.l #xx:32,erd 3 or.l ers,erd 2 orc orc #xx:8,ccr 1 orc #xx:8,exr 2 pop pop.w rn 1 1 1 pop.l ern 2 2 1 push push.w rn 1 1 1 push.l ern 2 2 1 rotl rotl.b rd 1 rotl.b #2,rd 1 rotl.w rd 1 rotl.w #2,rd 1 rotl.l erd 1 rotl.l #2,erd 1
815 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n rotr rotr.b rd 1 rotr.b #2,rd 1 rotr.w rd 1 rotr.w #2,rd 1 rotr.l erd 1 rotr.l #2,erd 1 rotxl rotxl.b rd 1 rotxl.b #2,rd 1 rotxl.w rd 1 rotxl.w #2,rd 1 rotxl.l erd 1 rotxl.l #2,erd 1 rotxr rotxr.b rd 1 rotxr.b #2,rd 1 rotxr.w rd 1 rotxr.w #2,rd 1 rotxr.l erd 1 rotxr.l #2,erd 1 rte rte 2 2/3 * 1 1 rts rts normal 2 1 1 advanced 2 2 1 shal shal.b rd 1 shal.b #2,rd 1 shal.w rd 1 shal.w #2,rd 1 shal.l erd 1 shal.l #2,erd 1 shar shar.b rd 1 shar.b #2,rd 1 shar.w rd 1 shar.w #2,rd 1 shar.l erd 1 shar.l #2,erd 1
816 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n shll shll.b rd 1 shll.b #2,rd 1 shll.w rd 1 shll.w #2,rd 1 shll.l erd 1 shll.l #2,erd 1 shlr shlr.b rd 1 shlr.b #2,rd 1 shlr.w rd 1 shlr.w #2,rd 1 shlr.l erd 1 shlr.l #2,erd 1 sleep sleep 1 1 stc stc.b ccr,rd 1 stc.b exr,rd 1 stc.w ccr,@erd 2 1 stc.w exr,@erd 2 1 stc.w ccr,@(d:16,erd) 3 1 stc.w exr,@(d:16,erd) 3 1 stc.w ccr,@(d:32,erd) 5 1 stc.w exr,@(d:32,erd) 5 1 stc.w ccr,@-erd 2 1 1 stc.w exr,@-erd 2 1 1 stc.w ccr,@aa:16 3 1 stc.w exr,@aa:16 3 1 stc.w ccr,@aa:32 4 1 stc.w exr,@aa:32 4 1 stm * 4 stm.l (ern-ern+1),@-sp 2 4 1 stm.l (ern-ern+2),@-sp 2 6 1 stm.l (ern-ern+3),@-sp 2 8 1 sub sub.b rs,rd 1 sub.w #xx:16,rd 2 sub.w rs,rd 1 sub.l #xx:32,erd 3 sub.l ers,erd 1
817 instruction mnemonic instruction fetch i branch address read j stack operation k byte data access l word data access m internal operation n subs subs #1/2/4,erd 1 subx subx #xx:8,rd 1 subx rs,rd 1 tas tas @erd * 3 22 trapa trapa #x:2 normal 2 1 2/3 * 1 2 advanced 2 2 2/3 * 1 2 xor xor.b #xx:8,rd 1 xor.b rs,rd 1 xor.w #xx:16,rd 2 xor.w rs,rd 1 xor.l #xx:32,erd 3 xor.l ers,erd 2 xorc xorc #xx:8,ccr 1 xorc #xx:8,exr 2 notes: 1. 2 when exr is invalid, 3 when valid. 2. when n bytes of data are transferred. 3. only register er0, er1, er4, or er5 should be used when using the tas instruction. 4. only registers er0 to er6 should be used when using the stm/ldm instruction.
818 a.5 bus states during instruction execution table a.6 indicates the types of cycles that occur during instruction execution by the cpu. see table a.4, number of states required for execution for the number of states per cycle. how to read the table: instruction jmp@aa:24 r:w 2nd internal operation, 2 state r:w ea 123 4 567 8 end of instruction order of execution read effective address (word-size read) no read or write read 2nd word of current instruction ( word-size read ) legend: r:b byte-size read r:w word-size read w:b byte-size write w:w word-size write :m transfer of the bus is not performed immediately after this cycle 2nd address of 2nd word (3rd and 4th bytes) 3rd address of 3rd word (5th and 6th bytes) 4th address of 4th word (7th and 8th bytes) 5th address of 5th word (9th and 10th bytes) next start address of instruction following executing instruction ea effective address vec vector address
819 figure a.1 shows timing waveforms for the address bus and the rd , hwr , and lwr signals during execution of the above instruction with an 8-bit bus, using three-state access with no wait states. ? address bus rd hwr , lwr r:w 2nd fetching 3rd byte of instruction fetching 4th byte of instruction fetching 1st byte of branch instruction fetching 2nd byte of branch instruction r:w ea high level internal operation figure a.1 address bus, rd , hwr , and lwr timing (8-bit bus, three-state access, no wait states)
820 table a.6 instruction execution cycle instruction 123456789 add.b #xx:8,rd r:w next add.b rs,rd r:w next add.w #xx:16,rd r:w 2nd r:w next add.w rs,rd r:w next add.l #xx:32,erd r:w 2nd r:w 3rd r:w next add.l ers,erd r:w next adds #1/2/4,erd r:w next addx #xx:8,rd r:w next addx rs,rd r:w next and.b #xx:8,rd r:w next and.b rs,rd r:w next and.w #xx:16,rd r:w 2nd r:w next and.w rs,rd r:w next and.l #xx:32,erd r:w 2nd r:w 3rd r:w next and.l ers,erd r:w 2nd r:w next andc #xx:8,ccr r:w next andc #xx:8,exr r:w 2nd r:w next band #xx:3,rd r:w next band #xx:3,@erd r:w 2nd r:b ea r:w:m next band #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next band #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next band #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bra d:8 (bt d:8) r:w next r:w ea brn d:8 (bf d:8) r:w next r:w ea bhi d:8 r:w next r:w ea bls d:8 r:w next r:w ea bcc d:8 (bhs d:8) r:w next r:w ea bcs d:8 (blo d:8) r:w next r:w ea bne d:8 r:w next r:w ea beq d:8 r:w next r:w ea bvc d:8 r:w next r:w ea bvs d:8 r:w next r:w ea bpl d:8 r:w next r:w ea
821 instruction 123456789 bmi d:8 r:w next r:w ea bge d:8 r:w next r:w ea blt d:8 r:w next r:w ea bgt d:8 r:w next r:w ea ble d:8 r:w next r:w ea bra d:16 (bt d:16) r:w 2nd internal operation, 1 state r:w ea brn d:16 (bf d:16) r:w 2nd internal operation, 1 state r:w ea bhi d:16 r:w 2nd internal operation, 1 state r:w ea bls d:16 r:w 2nd internal operation, 1 state r:w ea bcc d:16 (bhs d:16) r:w 2nd internal operation, 1 state r:w ea bcs d:16 (blo d:16) r:w 2nd internal operation, 1 state r:w ea bne d:16 r:w 2nd internal operation, 1 state r:w ea beq d:16 r:w 2nd internal operation, 1 state r:w ea bvc d:16 r:w 2nd internal operation, 1 state r:w ea bvs d:16 r:w 2nd internal operation, 1 state r:w ea bpl d:16 r:w 2nd internal operation, 1 state r:w ea bmi d:16 r:w 2nd internal operation, 1 state r:w ea bge d:16 r:w 2nd internal operation, 1 state r:w ea
822 instruction 123456789 blt d:16 r:w 2nd internal operation, 1 state r:w ea bgt d:16 r:w 2nd internal operation, 1 state r:w ea ble d:16 r:w 2nd internal operation, 1 state r:w ea bclr #xx:3,rd r:w next bclr #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bclr #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bclr#xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bclr#xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bclr rn,rd r:w next bclr rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bclr rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bclr rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bclr rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea biand #xx:3,rd r:w next biand #xx:3, @erd r:w 2nd r:b ea r:w:m next biand #xx:3, @aa:8 r:w 2nd r:b ea r:w:m next biand #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next biand #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bild #xx:3,rd r:w next bild #xx:3,@erd r:w 2nd r:b ea r:w:m next bild #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bild #xx:3,@aa:16 r:w 2nd r:w 3rd r:b: ea r:w:m next
823 instruction 123456789 bild #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bior #xx:3,rd r:w next bior #xx:3,@erd r:w 2nd r:b ea r:w:m next bior #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bior #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bior #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bist #xx:3,rd r:w next bist #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bist #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bixor #xx:3,rd r:w next bixor #xx:3, @erd r:w 2nd r:b ea r:w:m next bixor #xx:3, @aa:8 r:w 2nd r:b ea r:w:m next bixor #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bixor #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bld #xx:3,rd r:w next bld #xx:3,@erd r:w 2nd r:b ea r:w:m next bld #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bld #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bld #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bnot #xx:3,rd r:w next bnot #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea
824 instruction 123456789 bnot #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bnot #xx:3, @aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bnot #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bnot rn,rd r:w next bnot rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bnot rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bnot rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bnot rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bor #xx:3,rd r:w next bor #xx:3,@erd r:w 2nd r:b ea r:w:m next bor #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bor #xx:3,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bor #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w next bset #xx:3,rd r:w next bset #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bset #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bset #xx:3, @aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bset #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea bset rn,rd r:w next bset rn,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bset rn,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bset rn,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bset rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea
825 instruction 123456789 bsr d:8 advanced r:w next r:w ea w:w:m stack (h) w:w stack (l) bsr d:16 advanced r:w 2nd internal operation, 1 state r:w ea w:w:m stack (h) w:w stack (l) bst #xx:3,rd r:w next bst #xx:3,@erd r:w 2nd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:8 r:w 2nd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:16 r:w 2nd r:w 3rd r:b:m ea r:w:m next w:b ea bst #xx:3,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b:m ea r:w:m next w:b ea btst #xx:3,rd r:w next btst #xx:3,@erd r:w 2nd r:b ea r:w:m next btst #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next btst #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next btst #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next btst rn,rd r:w next btst rn,@erd r:w 2nd r:b ea r:w:m next btst rn,@aa:8 r:w 2nd r:b ea r:w:m next btst rn,@aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next btst rn,@aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next bxor #xx:3,rd r:w next bxor #xx:3,@erd r:w 2nd r:b ea r:w:m next bxor #xx:3,@aa:8 r:w 2nd r:b ea r:w:m next bxor #xx:3, @aa:16 r:w 2nd r:w 3rd r:b ea r:w:m next bxor #xx:3, @aa:32 r:w 2nd r:w 3rd r:w 4th r:b ea r:w:m next clrmac cannot be used in the lsi.
826 instruction 123456789 cmp.b #xx:8,rd r:w next cmp.b rs,rd r:w next cmp.w #xx:16,rd r:w 2nd r:w next cmp.w rs,rd r:w next cmp.l #xx:32,erd r:w 2nd r:w 3rd r:w next cmp.l ers,erd r:w next daa rd r:w next das rd r:w next dec.b rd r:w next dec.w #1/2,rd r:w next dec.l #1/2,erd r:w next divxs.b rs,rd r:w 2nd r:w next internal operation, 11 states divxs.w rs,erd r:w 2nd r:w next internal operation, 19 states divxu.b rs,rd r:w next internal operation, 11 states divxu.w rs,erd r:w next internal operation, 19 states eepmov.b r:w 2nd r:b eas * 1 r:b ead * 1 r:b eas * 2 w:b ead * 2 r:w next eepmov.w r:w 2nd r:b eas * 1 r:b ead * 1 r:b eas * 2 w:b ead * 2 r:w next exts.w rd r:w next repeated n times * 2 exts.l erd r:w next extu.w rd r:w next extu.l erd r:w next inc.b rd r:w next inc.w #1/2,rd r:w next inc.l #1/2,erd r:w next jmp @ern r:w next r:w ea jmp @aa:24 r:w 2nd internal operation, 1 state r:w ea jmp @@aa:8 advanced r:w next r:w:m aa:8 r:w aa:8 internal operation, 1 state r:w ea jsr @ern advanced r:w next r:w ea w:w:m stack (h) w:w stack (l) jsr @aa:24 advanced r:w 2nd internal operation, 1 state r:w ea w:w:m stack (h) w:w stack (l) jsr @@aa:8 advanced r:w next r:w:m aa:8 r:w aa:8 w:w:m stack (h) w:w stack (l) r:w ea
827 instruction 123456789 ldc #xx:8,ccr r:w next ldc #xx:8,exr r:w 2nd r:w next ldc rs,ccr r:w next ldc rs,exr r:w next ldc @ers,ccr r:w 2nd r:w next r:w ea ldc @ers,exr r:w 2nd r:w next r:w ea ldc@(d:16,ers), ccr r:w 2nd r:w 3rd r:w next r:w ea ldc@(d:16,ers), exr r:w 2nd r:w 3rd r:w next r:w ea ldc@(d:32,ers), ccr r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next r:w ea ldc@(d:32,ers), exr r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next r:w ea ldc @ers+,ccr r:w 2nd r:w next internal operation, 1 state r:w ea ldc @ers+,exr r:w 2nd r:w next internal operation, 1 state r:w ea ldc @aa:16,ccr r:w 2nd r:w 3rd r:w next r:w ea ldc @aa:16,exr r:w 2nd r:w 3rd r:w next r:w ea ldc @aa:32,ccr r:w 2nd r:w 3rd r:w 4th r:w next r:w ea ldc @aa:32,exr r:w 2nd r:w 3rd r:w 4th r:w next r:w ea ldm.l @sp+, (ern-ern+1) * 9 r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldm.l @sp+, (ern-ern+2) * 9 r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldm.l @sp+, (ern-ern+3) * 9 r:w 2nd r:w:m next internal operation, 1 state r:w:m stack (h) * 3 r:w stack (l) * 3 ldmac ers,mach cannot be used in the lsi. ldmac ers,macl mac @ern+, @erm+ mov.b #xx:8,rd r:w next mov.b rs,rd r:w next mov.b @ers,rd r:w next r:b ea mov.b @(d:16,ers),rd r:w 2nd r:w next r:b ea
828 instruction 123456789 mov.b @(d:32,ers),rd r:w 2nd r:w 3rd r:w 4th r:w next r:b ea mov.b @ers+,rd r:w next internal operation, 1 state r:b ea mov.b @aa:8,rd r:w next r:b ea mov.b @aa:16,rd r:w 2nd r:w next r:b ea mov.b @aa:32,rd r:w 2nd r:w 3rd r:w next r:b ea mov.b rs,@erd r:w next w:b ea mov.b rs, @(d:16,erd) r:w 2nd r:w next w:b ea mov.b rs, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w next w:b ea mov.b rs,@-erd r:w next internal operation, 1 state w:b ea mov.b rs,@aa:8 r:w next w:b ea mov.b rs,@aa:16 r:w 2nd r:w next w:b ea mov.b rs,@aa:32 r:w 2nd r:w 3rd r:w next w:b ea mov.w #xx:16,rd r:w 2nd r:w next mov.w rs,rd r:w next mov.w @ers,rd r:w next r:w ea mov.w @(d:16,ers),rd r:w 2nd r:w next r:w ea mov.w @(d:32,ers),rd r:w 2nd r:w 3rd r:w 4th r:w next r:w ea mov.w @ers+,rd r:w next internal operation, 1 state r:w ea mov.w @aa:16,rd r:w 2nd r:w next r:w ea mov.w @aa:32,rd r:w 2nd r:w 3rd r:w next r:b ea mov.w rs,@erd r:w next w:w ea mov.w rs, @(d:16,erd) r:w 2nd r:w next w:w ea mov.w rs, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w next w:w ea mov.w rs,@-erd r:w next internal operation, 1 state w:w ea mov.w rs,@aa:16 r:w 2nd r:w next w:w ea mov.w rs,@aa:32 r:w 2nd r:w 3rd r:w next w:w ea
829 instruction 123456789 mov.l #xx:32,erd r:w 2nd r:w 3rd r:w next mov.l ers,erd r:w next mov.l @ers,erd r:w 2nd r:w:m next r:w:m ea r:w ea+2 mov.l @(d:16,ers),erd r:w 2nd r:w:m 3rd r:w next r:w:m ea r:w ea+2 mov.l @(d:32,ers),erd r:w 2nd r:w:m 3rd r:w:m 4th r:w 5th r:w next r:w:m ea r:w ea+2 mov.l @ers+, erd r:w 2nd r:w:m next internal operation, 1 state r:w:m ea r:w ea+2 mov.l @aa:16, erd r:w 2nd r:w:m 3rd r:w next r:w:m ea r:w ea+2 mov.l @aa:32, erd r:w 2nd r:w:m 3rd r:w 4th r:w next r:w:m ea r:w ea+2 mov.l ers,@erd r:w 2nd r:w:m next w:w:m ea w:w ea+2 mov.l ers, @(d:16,erd) r:w 2nd r:w:m 3rd r:w next w:w:m ea w:w ea+2 mov.l ers, @(d:32,erd) r:w 2nd r:w:m 3rd r:w:m 4th r:w 5th r:w next w:w:m ea w:w ea+2 mov.l ers,@-erd r:w 2nd r:w:m next internal operation, 1 state w:w:m ea w:w ea+2 mov.l ers, @aa:16 r:w 2nd r:w:m 3rd r:w next w:w:m ea w:w ea+2 mov.l ers, @aa:32 r:w 2nd r:w:m 3rd r:w 4th r:w next w:w:m ea w:w ea+2 movfpe @aa:16,rd cannot be used in the lsi. movtpe rs,@aa:16 mulxs.b rs,rd r:w 2nd r:w next internal operation, 11 states mulxs.w rs,erd r:w 2nd r:w next internal operation, 19 states mulxu.b rs,rd r:w next internal operation, 11 states mulxu.w rs,erd r:w next internal operation, 19 states neg.b rd r:w next neg.w rd r:w next neg.l erd r:w next nop r:w next not.b rd r:w next not.w rd r:w next
830 instruction 123456789 not.l erd r:w next or.b #xx:8,rd r:w next or.b rs,rd r:w next or.w #xx:16,rd r:w 2nd r:w next or.w rs,rd r:w next or.l #xx:32,erd r:w 2nd r:w 3rd r:w next or.l ers,erd r:w 2nd r:w next orc #xx:8,ccr r:w next orc #xx:8,exr r:w 2nd r:w next pop.w rn r:w next internal operation, 1 state r:w ea pop.l ern r:w 2nd r:w:m next internal operation, 1 state r:w:m ea r:w ea+2 push.w rn r:w next internal operation, 1 state w:w ea push.l ern r:w 2nd r:w:m next internal operation, 1 state w:w:m ea w:w ea+2 rotl.b rd r:w next rotl.b #2,rd r:w next rotl.w rd r:w next rotl.w #2,rd r:w next rotl.l erd r:w next rotl.l #2,erd r:w next rotr.b rd r:w next rotr.b #2,rd r:w next rotr.w rd r:w next rotr.w #2,rd r:w next rotr.l erd r:w next rotr.l #2,erd r:w next rotxl.b rd r:w next rotxl.b #2,rd r:w next rotxl.w rd r:w next rotxl.w #2,rd r:w next rotxl.l erd r:w next
831 instruction 123456789 rotxl.l #2,erd r:w next rotxr.b rd r:w next rotxr.b #2,rd r:w next rotxr.w rd r:w next rotxr.w #2,rd r:w next rotxr.l erd r:w next rotxr.l #2,erd r:w next rte r:w next r:w stack (exr) r:w stack (h) r:w stack (l) internal operation, 1 state r:w * 4 rts advanced r:w next r:w:m stack (h) r:w stack (l) internal operation, 1 state r:w * 4 shal.b rd r:w next shal.b #2,rd r:w next shal.w rd r:w next shal.w #2,rd r:w next shal.l erd r:w next shal.l #2,erd r:w next shar.b rd r:w next shar.b #2,rd r:w next shar.w rd r:w next shar.w #2,rd r:w next shar.l erd r:w next shar.l #2,erd r:w next shll.b rd r:w next shll.b #2,rd r:w next shll.w rd r:w next shll.w #2,rd r:w next shll.l erd r:w next shll.l #2,erd r:w next shlr.b rd r:w next shlr.b #2,rd r:w next shlr.w rd r:w next shlr.w #2,rd r:w next shlr.l erd r:w next shlr.l #2,erd r:w next
832 instruction 123456789 sleep r:w next internal operation :m stc ccr,rd r:w next stc exr,rd r:w next stc ccr,@erd r:w 2nd r:w next w:w ea stc exr,@erd r:w 2nd r:w next w:w ea stc ccr, @(d:16,erd) r:w 2nd r:w 3rd r:w next w:w ea stc exr, @(d:16,erd) r:w 2nd r:w 3rd r:w next w:w ea stc ccr, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next w:w ea stc exr, @(d:32,erd) r:w 2nd r:w 3rd r:w 4th r:w 5th r:w next w:w ea stc ccr,@-erd r:w 2nd r:w next internal operation, 1 state w:w ea stc exr,@-erd r:w 2nd r:w next internal operation, 1 state w:w ea stc ccr,@aa:16 r:w 2nd r:w 3rd r:w next w:w ea stc exr,@aa:16 r:w 2nd r:w 3rd r:w next w:w ea stc ccr,@aa:32 r:w 2nd r:w 3rd r:w 4th r:w next w:w ea stc exr,@aa:32 r:w 2nd r:w 3rd r:w 4th r:w next w:w ea stm.l (ern-ern+1), @-sp * 9 r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stm.l (ern-ern+2), @-sp * 9 r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stm.l (ern-ern+3), @-sp * 9 r:w 2nd r:w:m next internal operation, 1 state w:w:m stack (h) * 3 w:w stack (l) * 3 stmac mach,erd cannot be used in the lsi. stmac macl,erd sub.b rs,rd r:w next sub.w #xx:16,rd r:w 2nd r:w next sub.w rs,rd r:w next sub.l #xx:32,erd r:w 2nd r:w 3rd r:w next sub.l ers,erd r:w next
833 instruction 123456789 subs #1/2/4,erd r:w next subx #xx:8,rd r:w next subx rs,rd r:w next tas @erd * 5 r:w 2nd r:w next r:b:m ea w:b ea trapa #x:2 advanced r:w next internal operation, 1 state w:w stack (l) w:w stack (h) w:w stack (exr) r:w:m vec r:w vec+2 internal operation, 1 state r:w * 8 xor.b #xx8,rd r:w next xor.b rs,rd r:w next xor.w #xx:16,rd r:w 2nd r:w next xor.w rs,rd r:w next xor.l #xx:32,erd r:w 2nd r:w 3rd r:w next xor.l ers,erd r:w 2nd r:w next xorc #xx:8,ccr r:w next xorc #xx:8,exr r:w 2nd r:w next reset excep- tion handling advanced r:w:m vec r:w vec+2 internal operation, 1 state r:w * 6 interrupt excep- tion handling advanced r:w * 7 internal operation, 1 state w:w stack (l) w:w stack (h) w:w stack (exr) r:w:m vec r:w vec+2 internal operation, 1 state r:w * 8 notes: 1. eas is the contents of er5. ead is the contents of er6. 2. eas is the contents of er5. ead is the contents of er6. both registers are incremented by 1 after execution of the instruction. n is the initial value of r4l or r4. if n = 0, these bus cycles are not executed. 3. repeated two times to save or restore two registers, three times for three registers, or four times for four registers. 4. start address after return. 5. only register er0, er1, er4, or er5 should be used when using the tas instruction. 6. start address of the program. 7. prefetch address, equal to two plus the pc value pushed onto the stack. in recovery from sleep mode or software standby mode the read operation is replaced by an internal operation. 8. start address of the interrupt-handling routine. 9. only registers er0 to er6 should be used when using the stm/ldm instruction.
834 appendix b internal i/o registers b.1 addresses address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ec00 m ra sm1 sm0 dm1 dm0 md1 md0 dts sz dtc 16/32 * to sar h'efff m rb chn e disel dar cra crb h'fe20 twr0mw bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 hif:lpc 8 twr0sw bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe21 twr1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe22 twr2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe23 twr3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe24 twr4 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe25 twr5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe26 twr6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe27 twr7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe28 twr8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe29 twr9 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2a twr10 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2b twr11 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2c twr12 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2d twr13 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2e twr14 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe2f twr15 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe30 idr3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
835 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fe31 odr3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 hif:lpc 8 h'fe32 str3 ibf3b obf3b mwmf swmf c/ d 3 dbu32 ibf3a obf3a h'fe34 ladr3h bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 h'fe35 ladr3l bit 7 bit 6 bit 5 bit 4 bit 3 bit 1 twre h'fe36 sirqcr0 q/ c iedir smie3b smie3a smie2 irq12e1 irq1e1 h'fe37 sirqcr1 irq11e3 irq10e3 irq9e3 irq6e3 irq11e2 irq10e2 irq9e2 irq6e2 h'fe38 idr1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe39 odr1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe3a str1 dbu17 dbu16 dbu15 dbu14 c/ d 1 dbu12 ibf1 obf1 h'fe3c idr2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe3d odr2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'fe3e str2 dbu27 dbu26 dbu25 dbu24 c/ d 2 dbu22 ibf2 obf2 h'fe40 hicr0 lpc3e lpc2e lpc1e fga20e sdwne pmee lsmie lscie h'fe41 hicr1 lpcbsy clkreq irqbsy lrstb sdwnb pmeb lsmib lscib h'fe42 hicr2 ga20 lrst sdwn abrt ibfie3 ibfie2 ibfie1 errie h'fe43 hicr3 lframe clkrun serirq lreset lpcpd pme lsmi lsci h'fe44 wuemrb wuemr7 wuemr6 wuemr5 wuemr4 wuemr3 wuemr2 wuemr1 wuemr0 interrupt 8 h'fe80 hicr2 ibfie4 ibfie3 hif:xbs 8 h'fe84 idr3 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 h'fe85 odr3 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 h'fe86 str3 dbu dbu dbu dbu c/ d dbu ibf obf h'fe8c idr4 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 h'fe8d odr4 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 h'fe8e str4 dbu dbu dbu dbu c/ d dbu ibf obf h'fed8 kbcrh0 kbioe kclki kdi kbfsel kbie kbf per kbs keyboard 8 h'fed9 kbcrl0 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 buffer h'feda kbbr0 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 controller h'fedc kbcrh1 kbioe kclki kdi kbfsel kbie kbf per kbs h'fedd kbcrl1 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 h'fede kbbr1 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 h'fee0 kbcrh2 kbioe kclki kdi kbfsel kbie kbf per kbs h'fee1 kbcrl2 kbe kclko kdo rxcr3 rxcr2 rxcr1 rxcr0 h'fee2 kbbr2 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0 h'fee4 kbcomp ire ircks2 ircks1 ircks0 kbade kbch2 kbch1 kbch0 irda/ expansion a/d 8 h'fee6 ddcswr swe sw ie if clr3 clr2 clr1 clr0 iic0 8
836 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fee8 icra icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 interrupt 8 h'fee9 icrb icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 controller h'feea icrc icr7 icr6 icr5 icr4 icr3 icr2 icr1 icr0 h'feeb isr irq7f irq6f irq5f irq4f irq3f irq2f irq1f irq0f h'feec iscrh irq7scb irq7sca irq6scb irq6sca irq5scb irq5sca irq4scb irq4sca h'feed iscrl irq3scb irq3sca irq2scb irq2sca irq1scb irq1sca irq0scb irq0sca h'feee dtcera dtcea7 dtcea6 dtcea5 dtcea4 dtcea3 dtcea2 dtcea1 dtcea0 dtc 8 h'feef dtcerb dtceb7 dtceb6 dtceb5 dtceb4 dtceb3 dtceb2 dtceb1 dtceb0 h'fef0 dtcerc dtcec7 dtcec6 dtcec5 dtcec4 dtcec3 dtcec2 dtcec1 dtcec0 h'fef1 dtcerd dtced7 dtced6 dtced5 dtced4 dtced3 dtced2 dtced1 dtced0 h'fef2 dtcere dtcee7 dtcee6 dtcee5 dtcee4 dtcee3 dtcee2 dtcee1 dtcee0 h'fef3 dtvecr swdte dtvec6 dtvec5 dtvec4 dtvec3 dtvec2 dtvec1 dtvec0 h'fef4 abrkcr cmf bie interrupt 8 h'fef5 bara a23 a22 a21 a20 a19 a18 a17 a16 controller h'fef6 barb a15 a14 a13 a12 a11 a10 a9 a8 h'fef7 barc a7 a6 a5 a4 a3 a2 a1 h'ff80 flmcr1 fwe swe ev pv e p flash 8 h'ff81 flmcr2 fler ?supsu h'ff82 pcsr pwckb pwcka pwm 8 ebr1 * * * * * * * * flash 8 h'ff83 syscr2 kwul1 kwul0 p6pue sde cs4e cs3e hi12e hif:xbs 8 ebr2 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 flash 8 h'ff84 sbycr ssby sts2 sts1 sts0 sck2 sck1 sck0 system 8 h'ff85 lpwrcr dton lson nesel excle h'ff86 mstpcrh mstp15 mstp14 mstp13 mstp12 mstp11 mstp10 mstp9 mstp8 h'ff87 mstpcrl mstp7 mstp6 mstp5 mstp4 mstp3 mstp2 mstp1 mstp0 h'ff88 smr1 c/ a chr pe o/ e stop mp cks1 cks0 sci1 8 iccr1 ice ieic mst trs acke bbsy iric scp iic1 h'ff89 brr1 sci1 8 icsr1 estp stop irtr aasx al aas adz ackb iic1 h'ff8a scr1 tie rie te re mpie teie cke1 cke0 sci1 8 h'ff8b tdr1 h'ff8c ssr1 tdre rdrf orer fer per tend mpb mpbt h'ff8d rdr1
837 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ff8e scmr1 sdir sinv smif sci1 8 icdr1 icdr7 icdr6 icdr5 icdr4 icdr3 icdr2 icdr1 icdr0 iic1 8 sarx1 svax6 svax5 svax4 svax3 svax2 svax1 svax0 fsx h'ff8f icmr1 mls wait cks2 cks1 cks0 bc2 bc1 bc0 sar1 sva6 sva5 sva4 sva3 sva2 sva1 sva0 fs h'ff90 tier iciae icibe icice icide ociae ocibe ovie frt 16 h'ff91 tcsr icfa icfb icfc icfd ocfa ocfb ovf cclra h'ff92 frch h'ff93 frcl h'ff94 ocrah ocrbh h'ff95 ocral ocrbl h'ff96 tcr iedga iedgb iedgc iedgd bufea bufeb cks1 cks0 h'ff97 tocr icrdms ocrams icrs ocrs oea oeb olvla olvlb h'ff98 icrah ocrarh h'ff99 icral ocrarl h'ff9a icrbh ocrafh h'ff9b icrbl ocrafl h'ff9c icrch ocrdmh h'ff9d icrcl ocrdml h'ff9e icrdh h'ff9f icrdl h'ffa0 smr2 c/ a chr pe o/ e stop mp cks1 cks0 sci2 8 dadrah da13 da12 da11 da10 da9 da8 da7 da6 pwmx dacr test pwme oeb oea os cks h'ffa1 brr2 sci2 8 dadral da5 da4 da3 da2 da1 da0 cfs pwmx
838 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffa2 scr2 tie rie te re mpie teie cke1 cke0 sci2 8 h'ffa3 tdr2 h'ffa4 ssr2 tdre rdrf orer fer per tend mpb mpbt h'ffa5 rdr2 h'ffa6 scmr2 sdir sinv smif dadrbh da13 da12 da11 da10 da9 da8 da7 da6 pwmx 8 dacnth h'ffa7 dadrbl da5 da4 da3 da2 da1 da0 cfs regs dacntl regs h'ffa8 tcsr0 ovf wt/ it tme rsts rst/ nmi cks2 cks1 cks0 wdt0 16 tcnt0 (write) h'ffa9 tcnt0 (read) h'ffaa paodr pa7odr pa6odr pa5odr pa4odr pa3odr pa2odr pa1odr pa0odr ports 8 h'ffab papin (read) pa7pin pa6pin pa5pin pa4pin pa3pin pa2pin pa1pin pa0pin paddr (write) pa7ddr pa6ddr pa5ddr pa4ddr pa3ddr pa2ddr pa1ddr pa0ddr h'ffac p1pcr p17pcr p16pcr p15pcr p14pcr p13pcr p12pcr p11pcr p10pcr h'ffad p2pcr p27pcr p26pcr p25pcr p24pcr p23pcr p22pcr p21pcr p20pcr h'ffae p3pcr p37pcr p36pcr p35pcr p34pcr p33pcr p32pcr p31pcr p30pcr h'ffb0 p1ddr p17ddr p16ddr p15ddr p14ddr p13ddr p12ddr p11ddr p10ddr h'ffb1 p2ddr p27ddr p26ddr p25ddr p24ddr p23ddr p22ddr p21ddr p20ddr h'ffb2 p1dr p17dr p16dr p15dr p14dr p13dr p12dr p11dr p10dr h'ffb3 p2dr p27dr p26dr p25dr p24dr p23dr p22dr p21dr p20dr h'ffb4 p3ddr p37ddr p36ddr p35ddr p34ddr p33ddr p32ddr p31ddr p30ddr h'ffb5 p4ddr p47ddr p46ddr p45ddr p44ddr p43ddr p42ddr p41ddr p40ddr h'ffb6 p3dr p37dr p36dr p35dr p34dr p33dr p32dr p31dr p30dr h'ffb7 p4dr p47dr p46dr p45dr p44dr p43dr p42dr p41dr p40dr h'ffb8 p5ddr p52ddr p51ddr p50ddr h'ffb9 p6ddr p67ddr p66ddr p65ddr p64ddr p63ddr p62ddr p61ddr p60ddr h'ffba p5dr p52dr p51dr p50dr h'ffbb p6dr p67dr p66dr p65dr p64dr p63dr p62dr p61dr p60dr h'ffbc pbodr pb7odr pb6odr pb5odr pb4odr pb3odr pb2odr pb1odr pb0odr h'ffbd pbpin (read) pb7pin pb6pin pb5pin pb4pin pb3pin pb2pin pb1pin pb0pin p8ddr (write) p86ddr p85ddr p84ddr p83ddr p82ddr p81ddr p80ddr
839 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffbe p7pin (read) p77pin p76pin p75pin p74pin p73pin p72pin p71pin p70pin ports 8 pbddr (write) pb7ddr pb6ddr pb5ddr pb4ddr pb3ddr pb2ddr pb1ddr pb0ddr h'ffbf p8dr p86dr p85dr p84dr p83dr p82dr p81dr p80dr h'ffc0 p9ddr p97ddr p96ddr p95ddr p94ddr p93ddr p92ddr p91ddr p90ddr h'ffc1 p9dr p97dr p96dr p95dr p94dr p93dr p92dr p91dr p90dr h'ffc2 ier irq7e irq6e irq5e irq4e irq3e irq2e irq1e irq0e interrupt controller 8 h'ffc3 stcr iics iicx1 iicx0 iice flshe icks1 icks0 system 8 h'ffc4 syscr cs2e iose intm1 intm0 xrst nmieg hie rame h'ffc5 mdcr expe mds1 mds0 h'ffc6 bcr icis1 icis0 brstrm brsts1 brsts0 ios1 ios0 bus 8 h'ffc7 wscr rams ram0 abw ast wms1 wms0 wc1 wc0 controller h'ffc8 tcr0 cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmr0, 16 h'ffc9 tcr1 cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmr1 h'ffca tcsr0 cmfb cmfa ovf adte os3 os2 os1 os0 h'ffcb tcsr1 cmfb cmfa ovf os3 os2 os1 os0 h'ffcc tcora0 h'ffcd tcora1 h'ffce tcorb0 h'ffcf tcorb1 h'ffd0 tcnt0 h'ffd1 tcnt1 h'ffd2 pwoerb oe15 oe14 oe13 oe12 oe11 oe10 oe9 oe8 pwm 8 h'ffd3 pwoera oe7 oe6 oe5 oe4 oe3 oe2 oe1 oe0 h'ffd4 pwdprb os15 os14 os13 os12 os11 os10 os9 os8 h'ffd5 pwdpra os7 os6 os5 os4 os3 os2 os1 os0 h'ffd6 pwsl pwcke pwcks rs3 rs2 rs1 rs0 h'ffd7 pwdr0 to pwdr15 h'ffd8 smr0 c/ a chr pe o/ e stop mp cks1 cks0 sci0 8 iccr0 ice ieic mst trs acke bbsy iric scp iic0 h'ffd9 brr0 sci0 icsr0 estp stop irtr aasx al aas adz ackb iic0
840 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'ffda scr0 tie rie te re mpie teie cke1 cke0 sci0 8 h'ffdb tdr0 h'ffdc ssr0 tdre rdrf orer fer per tend mpb mpbt h'ffdd rdr0 h'ffde scmr0 sdir sinv smif icdr0 icdr7 icdr6 icdr5 icdr4 icdr3 icdr2 icdr1 icdr0 iic0 sarx0 svax6 svax5 svax4 svax3 svax2 svax1 svax0 fsx h'ffdf icmr0 mls wait cks2 cks1 cks0 bc2 bc1 bc0 sar0 sva6 sva5 sva4 sva3 sva2 sva1 sva0 fs h'ffe0 addrah ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 a/d 8 h'ffe1 addral ad1 ad0 h'ffe2 addrbh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe3 addrbl ad1 ad0 h'ffe4 addrch ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe5 addrcl ad1 ad0 h'ffe6 addrdh ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'ffe7 addrdl ad1 ad0 h'ffe8 adcsr adf adie adst scan cks ch2 ch1 ch0 h'ffe9 adcr trgs1 trgs0 h'ffea tcsr1 ovf wt/ it tme pss rst/ nmi cks2 cks1 cks0 wdt1 16 tcnt1 (write) h'ffeb tcnt1 (read) h'fff0 hicr ibfie2 ibfie1 fga20e hif : xbs 8 tcrx cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmrx tcry cmieb cmiea ovie cclr1 cclr0 cks2 cks1 cks0 tmry h'fff1 kmimr kmimr7 kmimr6 kmimr5 kmimr4 kmimr3 kmimr2 kmimr1 kmimr0 interrupt controller 8 tcsrx cmfb cmfa ovf icf os3 os2 os1 os0 tmrx tcsry cmfb cmfa ovf icie os3 os2 os1 os0 tmry h'fff2 kmpcr km7pcr km6pcr km5pcr km4pcr km3pcr km2pcr km1pcr km0pcr ports ticrr tmrx tcoray tmry h'fff3 kmimra kmimr15 kmimr14 kmimr13 kmimr12 kmimr11 kmimr10 kmimr9 kmimr8 interrupt controller 8 ticrf tmrx tcorby tmry
841 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fff4 idr1 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 hif:xbs 8 tcntx tmrx tcnty tmry h'fff5 odr1 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 hif:xbs tcorc tmrx tisr ?s tmry h'fff6 str1 dbu dbu dbu dbu c/ d dbu ibf obf hif:xbs tcorax tmrx h'fff7 tcorbx h'fff8 dadr0 d/a h'fff9 dadr1 h'fffa dacr daoe1 daoe0 dae h'fffc idr2 idr7 idr6 idr5 idr4 idr3 idr2 idr1 idr0 hif:xbs tconri simod1 simod0 scone icst hfinv vfinv hiinv viinv timer connection h'fffd odr2 odr7 odr6 odr5 odr4 odr3 odr2 odr1 odr0 hif:xbs tconro hoe voe cloe cboe hoinv voinv cloinv cboinv timer connection h'fffe str2 dbu dbu dbu dbu c/ d dbu ibf obf hif:xbs tconrs tmrx/y isgene homod1 homod0 vomod1 vomod0 clmod1 clmod0 timer h'ffff sedgr vedg hedg cedg hfedg vfedg preqf ihi ivi connection h'fe16 pgnocr pg7noc pg6noc pg5noc pg4noc pg3noc pg2noc pg1noc pg0noc additional ports in h8s/2169 h'fe18 penocr pe7noc pe6noc pe5noc pe4noc pe3noc pe2noc pe1noc pe0noc h'fe19 pfnocr pf7noc pf6noc pf5noc pf4noc pf3noc pf2noc pf1noc pf0noc h'fe1c pcnocr pc7noc pc6noc pc5noc pc4noc pc3noc pc2noc pc1noc pc0noc h'fe1d pdnocr pd7noc pd6noc pd5noc pd4noc pd3noc pd2noc pd1noc pd0noc h'fe46 pgodr pg7odr pg6odr pg5odr pg4odr pg3odr pg2odr pg1odr pg0odr h'fe47 pgpin (read) pg7pin pg6pin pg5pin pg4pin pg3pin pg2pin pg1pin pg0pin pgddr (write) pg7ddr pg6ddr pg5ddr pg4ddr pg3ddr pg2ddr pg1ddr pg0ddr h'fe48 peodr pe7odr pe6odr pe5odr pe4odr pe3odr pe2odr pe1odr pe0odr h'fe49 pfodr pf7odr pf6odr pf5odr pf4odr pf3odr pf2odr pf1odr pf0odr h'fe4a pepin (read) pe7pin pe6pin pe5pin pe4pin pe3pin p32pin pe1pin pe0pin peddr (write) pe7ddr pe6ddr pe5ddr pe4ddr pe3ddr pe2ddr pe1ddr pe0ddr
842 address register name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name bus width h'fe4b pfpin (read) pf7pin pf6pin pf5pin pf4pin pf3pin pf2pin pf1pin pf0pin additional ports in h8s/2169 8 pfddr (write) pf7ddr pf6ddr pf5ddr pf4ddr pf3ddr pf2ddr pf1ddr pf0ddr h'fe4c pcodr pc7odr pc6odr pc5odr pc4odr pc3odr pc2odr pc1odr pc0odr h'fe4d pdodr pd7odr pd6odr pd5odr pd4odr pd3odr pd2odr pd1odr pd0odr h'fe4e pcpin (read) pc7pin pc6pin pc5pin pc4pin pc3pin pc2pin pc1pin pc0pin pcddr (write) pc7ddr pc6ddr pc5ddr pc4ddr pc3ddr pc2ddr pc1ddr pc0ddr h'fe4f pdpin (read) pd7pin pd6pin pd5pin pd4pin pd3pin pd2pin pd1pin pd0pin pdddr (write) pd7ddr pd6ddr pd5ddr pd4ddr pd3ddr pd2ddr pd1ddr pd0ddr note: * this bit must not be set to 1.
843 b.2 register selection conditions lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ec00 to mra rame = 1 in syscr dtc h'efff sar mrb dar cra crb h'fe16 pgnocr no conditions ports h'fe18 penocr h'fe19 pfnocr h'fe1c pcnocr h'fe1d pdnocr h'fe20 twr0mw mstp0 = 0, (hi12e = 0) * hif:lpc twr0sw h'fe21 twr1 h'fe22 twr2 h'fe23 twr3 h'fe24 twr4 h'fe25 twr5 h'fe26 twr6 h'fe27 twr7 h'fe28 twr8 h'fe29 twr9 h'fe2a twr10 h'fe2b twr11 h'fe2c twr12 h'fe2d twr13 h'fe2e twr14 h'fe2f twr15 h'fe30 idr3 h'fe31 odr3 h'fe32 str3 h'fe34 ladr3h h'fe35 ladr3l
844 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'fe36 sirqcr0 mstp0 = 0, (hi12e = 0) * hif:lpc h'fe37 sirqcr1 h'fe38 idr1 h'fe39 odr1 h'fe3a str1 h'fe3c idr2 h'fe3d odr2 h'fe3e str2 h'fe40 hicr0 h'fe41 hicr1 h'fe42 hicr2 h'fe43 hicr3 h'fe44 wuemrb no conditions interrupt controller h'fe46 pgodr no conditions ports h'fe47 pgpin (read) pgddr (write) h'fe48 peodr h'fe49 pfodr h'fe4a pepin (read) peddr (write) h'fe4b pfpin (read) pfddr (write) h'fe4c pcodr h'fe4d pdodr h'fe4e pcpin (read) pcddr (write) h'fe4f pdpin (read) pdddr (write) h'fe80 hicr2 mstp2 = 0 hif:xbs h'fe84 idr3 h'fe85 odr3 h'fe86 str3 h'fe8c idr4 h'fe8d odr4 h'fe8e str4
845 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'fed8 kbcrh0 mstp2 = 0 keyboard buffer h'fed9 kbcrl0 controller h'feda kbbr0 h'fedc kbcrh1 h'fedd kbcrl1 h'fede kbbr1 h'fee0 kbcrh2 h'fee1 kbcrl2 h'fee2 kbbr2 h'fee4 kbcomp no conditions irda/ expansion a/d h'fee6 ddcswr mstp4 = 0 iic0 h'fee8 icra no conditions interrupt controller h'fee9 icrb h'feea icrc h'feeb isr h'feec iscrh h'feed iscrl h'feee dtcera no conditions dtc h'feef dtcerb h'fef0 dtcerc h'fef1 dtcerd h'fef2 dtcere h'fef3 dtvecr h'fef4 abrkcr no conditions interrupt controller h'fef5 bara h'fef6 barb h'fef7 barc h'ff80 flmcr1 flshe = 1 in stcr flash memory h'ff81 flmcr2 h'ff82 pcsr flshe = 0 in stcr pwm ebr1 flshe = 1 in stcr flash memory h'ff83 syscr2 flshe = 0 in stcr hif:xbs ebr2 flshe = 1 in stcr flash memory
846 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ff84 sbycr flshe = 0 in stcr system h'ff85 lpwrcr h'ff86 mstpcrh h'ff87 mstpcrl h'ff88 smr1 mstp6 = 0, iice = 0 in stcr sci1 iccr1 mstp3 = 0, iice = 1 in stcr iic1 h'ff89 brr1 mstp6 = 0, iice = 0 in stcr sci1 icsr1 mstp3 = 0, iice = 1 in stcr iic1 h'ff8a scr1 mstp6 = 0 sci1 h'ff8b tdr1 h'ff8c ssr1 h'ff8d rdr1 h'ff8e scmr1 mstp6 = 0, iice = 0 in stcr icdr1 mstp3 = 0, iice = 1 ice = 1 in iccr1 iic1 sarx1 in stcr ice = 0 in iccr1 h'ff8f icmr1 ice = 1 in iccr1 sar1 ice = 0 in iccr1 h'ff90 tier mstp13 = 0 frt h'ff91 tcsr h'ff92 frch h'ff93 frcl h'ff94 ocrah ocrs = 0 in tocr ocrbh ocrs = 1 in tocr h'ff95 ocral ocrs = 0 in tocr ocrbl ocrs = 1 in tocr
847 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ff96 tcr mstp13 = 0 frt h'ff97 tocr h'ff98 icrah icrs = 0 in tocr ocrarh icrs = 1 in tocr h'ff99 icral icrs = 0 in tocr ocrarl icrs = 1 in tocr h'ff9a icrbh icrs = 0 in tocr ocrafh icrs = 1 in tocr h'ff9b icrbl icrs = 0 in tocr ocrafl icrs = 1 in tocr h'ff9c icrch icrs = 0 in tocr ocrdmh icrs = 1 in tocr h'ff9d icrcl icrs = 0 in tocr ocrdml icrs = 1 in tocr h'ff9e icrdh h'ff9f icrdl h'ffa0 smr2 mstp5 = 0, iice = 0 in stcr sci2 dadrah mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacr regs = 1 in dacnt/ dadrb h'ffa1 brr2 mstp5 = 0, iice = 0 in stcr sci2 dadral mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx
848 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ffa2 scr2 mstp5 = 0 sci2 h'ffa3 tdr2 h'ffa4 ssr2 h'ffa5 rdr2 h'ffa6 scmr2 mstp5 = 0, iice = 0 in stcr sci2 dadrbh mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacnth regs = 1 in dacnt/ dadrb h'ffa7 dadrbl mstp11 = 0, iice = 1 in stcr regs = 0 in dacnt/ dadrb pwmx dacntl regs = 1 in dacnt/ dadrb h'ffa8 tcsr0 no conditions wdt0 tcnt0 (write) h'ffa9 tcnt0 (read) h'ffaa paodr0 no conditions ports h'ffab papin (read) paddr (write) h'ffac p1pcr h'ffad p2pcr h'ffae p3pcr h'ffb0 p1ddr h'ffb1 p2ddr h'ffb2 p1dr h'ffb3 p2dr h'ffb4 p3ddr h'ffb5 p4ddr h'ffb6 p3dr h'ffb7 p4dr h'ffb8 p5ddr h'ffb9 p6ddr h'ffba p5dr
849 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ffbb p6dr no conditions ports h'ffbc pbodr h'ffbd p8ddr (write) pbpin (read) h'ffbe p7pin (read) pbddr (write) h'ffbf p8dr h'ffc0 p9ddr h'ffc1 p9dr h'ffc2 ier no conditions interrupt controller h'ffc3 stcr no conditions system h'ffc4 syscr h'ffc5 mdcr h'ffc6 bcr bus controller h'ffc7 wscr h'ffc8 tcr0 mstp12 = 0 tmr0, tmr1 h'ffc9 tcr1 h'ffca tcsr0 h'ffcb tcsr1 h'ffcc tcora0 h'ffcd tcora1 h'ffce tcorb0 h'ffcf tcorb1 h'ffd0 tcnt0 h'ffd1 tcnt1 h'ffd2 pwoerb no conditions pwm h'ffd3 pwoera h'ffd4 pwdprb h'ffd5 pwdpra h'ffd6 pwsl mstp11 = 0 h'ffd7 pwdr0 to pwdr15 h'ffd8 smr0 mstp7 = 0, iice = 0 in stcr sci0 iccr0 mstp4 = 0, iice = 1 in stcr iic0
850 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'ffd9 brr0 mstp7 = 0, iice = 0 in stcr sci0 icsr0 mstp4 = 0, iice = 1 in stcr iic0 h'ffda scr0 mstp7 = 0 sci0 h'ffdb tdr0 h'ffdc ssr0 h'ffdd rdr0 h'ffde scmr0 mstp7 = 0, iice = 0 in stcr icdr0 mstp4 = 0, iice = 1 in ice = 1 in iccr0 iic0 sarx0 stcr ice = 0 in iccr0 h'ffdf icmr0 ice = 1 in iccr0 sar0 ice = 0 in iccr0 h'ffe0 addrah mstp9 = 0 a/d h'ffe1 addral h'ffe2 addrbh h'ffe3 addrbl h'ffe4 addrch h'ffe5 addrcl h'ffe6 addrdh h'ffe7 addrdl h'ffe8 adcsr h'ffe9 adcr h'ffea tcsr1 no conditions wdt1 tcnt1 (write) h'ffeb tcnt1 (read) h'fff0 hicr mstp2 = 0, hie = 1 in syscr hif:xbs tcrx mstp8 = 0, hie = 0 in syscr tmrx/y = 0 in tconrs tmrx tcry tmrx/y = 1 in tconrs tmry
851 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'fff1 kmimr mstp2 = 0, hie = 1 in syscr interrupt controller tcsrx mstp8 = 0, hie = 0 in tmrx/y = 0 in tconrs tmrx tcsry syscr tmrx/y = 1 in tconrs tmry h'fff2 kmpcr mstp2 = 0, hie = 1 in syscr ports ticrr mstp8 = 0, hie = 0 in tmrx/y = 0 in tconrs tmrx tcoray syscr tmrx/y = 1 in tconrs tmry h'fff3 kmimra mstp2 = 0, hie = 1 in syscr interrupt controller ticrf mstp8 = 0, hie = 0 tmrx/y = 0 in tconrs tmrx tcorby in syscr tmrx/y = 1 in tconrs tmry h'fff4 idr1 mstp2 = 0, hie = 1 in syscr hif:xbs tcntx mstp8 = 0, hie = 0 tmrx/y = 0 in tconrs tmrx tcnty in syscr tmrx/y = 1 in tconrs tmry h'fff5 odr1 mstp2 = 0, hie = 1 in syscr hif:xbs tcorc mstp8 = 0, hie = 0 tmrx/y = 0 in tconrs tmrx tisr in syscr tmrx/y = 1 in tconrs tmry h'fff6 str1 mstp2 = 0, hie = 1 in syscr hif:xbs tcorax mstp8 = 0, hie = 0 tmrx/y = 0 in tconrs tmrx h'fff7 tcorbx in syscr h'fff8 dadr0 mstp10 = 0 d/a h'fff9 dadr1 h'fffa dacr
852 lower address register name h8s/2149 register selection conditions h8s/2169 register selection conditions module name h'fffc idr2 mstp2 = 0, hie = 1 in syscr hif:xbs tconri mstp8 = 0, hie = 0 in syscr timer connection h'fffd odr2 mstp2 = 0, hie = 1 in syscr hif:xbs tconro mstp8 = 0, hie = 0 in syscr timer connection h'fffe str2 mstp2 = 0, hie = 1 in syscr hif:xbs tconrs mstp8 = 0, hie = 0 timer connection h'ffff sedgr in syscr note: * the settings of hif:xbs related bits do not affect the operation of the hif:lpc. however, for reasons relating to the configuration of the program development tool (emulator), when the hif:lpc is used, bit hi12e in syscr2 should not be set to 1.
853 b.3 functions dacr?/a control register h'fffa d/a converter register name address to which the register is mapped name of on-chip supporting module register acronym bit numbers initial bit values names of the bits. dashes (? indicate reserved bits. full name of bit descriptions of bit settings read only write only read and write r w r/w possible types of access bit initial value read/write 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 1 3 1 0 1 2 1 1 1 d/a enabled daoe1 0 1 conversion result dae * 0 1 0 1 * daoe0 0 1 0 1 channel 0 and 1 d/a conversion disabled channel 0 d/a conversion enabled channel 1 d/a conversion disabled channel 0 and 1 d/a conversion enabled channel 0 d/a conversion disabled channel 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled d/a output enable 0 0 analog output da0 disabled 1 channel 0 d/a conversion enabled. analog output da0 enabled d/a output enable 1 0 analog output da1 disabled 1 channel 1 d/a conversion enabled. analog output da1 enabled
854 mra?tc mode register a h'ec00?'efff dtc 7 sm1 undefined 6 sm0 undefined 5 dm1 undefined 4 dm0 undefined 3 md1 undefined 0 sz undefined 2 md0 undefined 1 dts undefined bit initial value read/write dtc data transfer size 0 byte-size transfer 1 word-size transfer dtc transfer mode select 0 destination side is repeat area or block area 1 source side is repeat area or block area dtc mode 0 normal mode repeat mode 0 1 1 block transfer mode 0 1 destination address mode 0 dar is fixed dar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 0 1 dar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1 source address mode 0 sar is fixed sar is incremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 0 1 sar is decremented after a transfer (by 1 when sz = 0; by 2 when sz = 1) 1
855 mrb?tc mode register b h'ec00?'efff dtc 7 chne undefined 6 disel undefined 5 undefined 4 undefined 3 undefined 0 undefined 2 undefined 1 undefined bit initial value read/write dtc interrupt select 0 after a data transfer ends, the cpu interrupt is disabled unless the transfer counter is 0 1 after a data transfer ends, the cpu interrupt is enabled dtc chain transfer enable 0 end of dtc data transfer 1 dtc chain transfer sar?tc source address register h'ec00?'efff dtc 23 unde- fined bit initial value read/write 22 unde- fined 21 unde- fined 20 unde- fined 19 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined - - - - - - - - - - - - specifies dtc transfer data source address dar?tc destination address register h'ec00?'efff dtc 23 unde- fined bit initial value read/write 22 unde- fined 21 unde- fined 20 unde- fined 19 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined - - - - - - - - - - - - specifies dtc transfer data destination address
856 cra?tc transfer count register a h'ec00?'efff dtc 15 unde- fined bit initial value read/write 14 unde- fined 13 unde- fined 12 unde- fined 11 unde- fined 10 unde- fined 9 unde- fined 8 unde- fined 7 unde- fined 6 unde- fined 5 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined crah cral specifies the number of dtc data transfers crb?tc transfer count register b h'ec00?'efff dtc 15 unde- fined bit initial value read/write 14 unde- fined 13 unde- fined 12 unde- fined 11 unde- fined 10 unde- fined 9 unde- fined 8 unde- fined 7 unde- fined 6 unde- fined 5 unde- fined 4 unde- fined 3 unde- fined 2 unde- fined 1 unde- fined 0 unde- fined specifies the number of dtc block data transfers
857 twr0 to twr15?wo-way data register h'fe20?'fe2f hif (lpc) 7 bit 7 r w 6 bit 6 r w 5 bit 5 r w 4 bit 4 r w 3 bit 3 r w 0 bit 0 r w 2 bit 2 r w 1 bit 1 r w bit initial value slave read/write host read/write ? twr0mw ? twr0sw ? twr1 to twr15 7 bit 7 w r 6 bit 6 w r 5 bit 5 w r 4 bit 4 w r 3 bit 3 w r 0 bit 0 w r 2 bit 2 w r 1 bit 1 w r bit initial value slave read/write host read/write 7 bit 7 r/w r/w 6 bit 6 r/w r/w 5 bit 5 r/w r/w 4 bit 4 r/w r/w data register accessible by both host and slave 3 bit 3 r/w r/w 0 bit 0 r/w r/w 2 bit 2 r/w r/w 1 bit 1 r/w r/w bit initial value slave read/write host read/write
858 idr3?nput data register 3 h'fe30 hif (lpc) idr1?nput data register 1 h'fe38 hif (lpc) idr2?nput data register 2 h'fe3c hif (lpc) 7 bit 7 r w 6 bit 6 r w 5 bit 5 r w 4 bit 4 r w written by host using i/o address in table below * 3 bit 3 r w 0 bit 0 r w 2 bit 2 r w 1 bit 1 r w bit initial value slave read/write host read/write i/o address host register selection transfer cycle bits 15 to 4 bit 3 0 0 0 0 bit 2 0 1 0 1 bit 1 0 0 1 1 bit 0 0 0 0 0 i/o write i/o write i/o write i/o write idr1 write, c/ d 1 0 idr1 write, c/ d 1 1 idr2 write, c/ d 2 0 idr2 write, c/ d 2 1 0000 0000 0110 0000 0000 0110 0000 0000 0110 0000 0000 0110 note: * for information on idr3 selection, see lpc channel 3 address register (ladr3).
859 odr3?utput data register 3 h'fe31 hif (lpc) odr1?utput data register 1 h'fe39 hif (lpc) odr2?utput data register 2 h'fe3d hif (lpc) 7 bit 7 r/w r 6 bit 6 r/w r 5 bit 5 r/w r 4 bit 4 r/w r read by host using i/o address in table below * 3 bit 3 r/w r 0 bit 0 r/w r 2 bit 2 r/w r 1 bit 1 r/w r bit initial value slave read/write host read/write i/o address host register selection transfer cycle bits 15 to 4 bit 3 0 0 bit 2 0 0 bit 1 0 1 bit 0 0 0 i/o read i/o read odr1 read odr2 read 0000 0000 0110 0000 0000 0110 note: * for information on odr3 selection, see lpc channel 3 address register (ladr3).
860 str3?tatus register 3 h'fe32 hif (lpc) 7 ibf3b 0 r r 6 obf3b 0 r/(w) * r 5 mwmf 0 r r 4 swmf 0 r/(w) * r 3 c/ d 3 0 r r 0 obf3a 0 r/(w) * r 2 dbu32 0 r/w r 1 ibf3a 0 r r bit initial value slave read/write host read/write note: * only 0 can be written, to clear the flag. output data register full 0 [clearing condition] host reads odr using i/o read cycle, or slave writes 0 to obf bit 1 [setting condition] slave writes to odr input data register full user-defined bit 0 [clearing condition] slave reads idr 1 [setting condition] host writes to idr using i/o write cycle command/data 0 input data register (idr) contents are data 1 input data register (idr) contents are a command slave write mode flag 0 [clearing condition] host reads twr15 using i/o read cycle, or slave writes 0 to swmf bit 1 [setting condition] slave writes to twr0 when mwmf = 0 master write mode flag 0 [clearing condition] slave reads twr15 1 [setting condition] host writes to twr0 using i/o write cycle when swmf = 0 two-way register input data full 0 [clearing condition] slave reads twr15 1 [setting condition] host writes to twr15 using i/o write cycle two-way register output data full 0 [clearing condition] host reads twr15 using i/o read cycle, or slave writes 0 to obf3b bit 1 [setting condition] slave writes to twr15
861 str1?tatus register 1 h'fe3a hif (lpc) str2?tatus register 2 h'fe3e hif (lpc) 7 dbu17 0 r/w r 6 dbu16 0 r/w r 5 dbu15 0 r/w r 4 dbu14 0 r/w r 3 c/ d 1 0 r r 0 obf1 0 r/(w) * r 2 dbu12 0 r/w r 1 ibf1 0 r r bit initial value slave read/write host read/write ? str1 7 dbu27 0 r/w r 6 dbu26 0 r/w r 5 dbu25 0 r/w r 4 dbu24 0 r/w r 3 c/ d 2 0 r r 0 obf2 0 r/(w) * r 2 dbu22 0 r/w r 1 ibf2 0 r r bit initial value slave read/write host read/write ? str2 output data register full 0 [clearing condition] host reads odr using i/o read cycle, or slave writes 0 to obf bit 1 [setting condition] slave writes to odr input data register full 0 [clearing condition] slave reads idr 1 [setting condition] host writes to idr using i/o write cycle command/data 0 input data register (idr) contents are data 1 input data register (idr) contents are a command note: * only 0 can be written, to clear the flag. user-defined bits
862 ladr3h?pc channel 3 address register h h'fe34 hif (lpc) ladr3l?pc channel 3 address register l h'fe35 hif (lpc) ladr3h ladr3l bit 7654321076543210 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 1 twre initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w idr3, odr3, str3 address bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 1/0 bit 1 0 twr0?wr15 address bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 1/0 1/0 1/0 1/0 channel 3 address bits 15 to 3 and 1 register selection according to the bits ignored in address match determination is as shown in the following table. i/o address transfer bit 4 bit 3 bit 2 bit 1 bit 0 cycle host register selection bit 4 bit 3 0 bit 1 0 i/o write idr3 write, c/ d 3 ? 0 bit 4 bit 3 1 bit 1 0 i/o write idr3 write, c/ d 3 ? 1 bit 4 bit 3 0 bit 1 0 i/o read odr3 read bit 4 bit 3 1 bit 1 0 i/o read str3 read bit 4 0000 i/o write twr0mw write bit 4 0001 i/o write twr1 write to twr15 write 1111 bit 4 0000 i/o read twr0sw read bit 4 0001 i/o read twr1 read to twr15 read 1111 two-way register enable ladr3l bit 0 description twre 0 twr operation is disabled twr-related i/o address match determination is halted 1 twr operation is enabled
863 sirqcr0?erirq control register 0 h'fe36 hif (lpc) 7 q/ c 0 r 6 0 r/w 5 iedir 0 r/w 4 smie3b 0 r/w 3 smie3a 0 r/w 0 irq1e1 0 r/w 2 smie2 0 r/w 1 irq12e1 0 r/w bit initial value slave read/write host read/write hirq1 interrupt enable 1 0 hirq1 interrupt request by obf1 and irq1e1 is disabled [clearing conditions] writing 0 to irq1e1 lpc hardware reset, lpc software reset clearing obf1 to 0 1 hirq1 interrupt request by setting obf1 to 1 is enabled [setting condition] writing 1 after reading irq1e1 = 0 hirq12 interrupt enable 1 0 hirq12 interrupt request by obf1 and irq12e1 is disabled [clearing conditions] writing 0 to irq12e1 lpc hardware reset, lpc software reset clearing obf1 to 0 1 hirq12 interrupt request by setting obf1 to 1 is enabled [setting condition] writing 1 after reading irq12e1 = 0 smi interrupt enable 2 0 smi interrupt request by obf2 and smie2 is disabled [clearing conditions] writing 0 to smie2 lpc hardware reset, lpc software reset clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf2 to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] writing 1 after reading smie2 = 0 smi interrupt enable 3a 0 smi interrupt request by obf3a and smie3a is disabled [clearing conditions] writing 0 to smie3a lpc hardware reset, lpc software reset clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf3a to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] writing 1 after reading smie3a = 0 smi interrupt enable 3b 0 smi interrupt request by obf3b and smie3b is disabled [clearing conditions] writing 0 to smie3b lpc hardware reset, lpc software reset clearing obf3b to 0 (when iedir = 0) 1 [when iedir = 0] smi interrupt request by setting obf3b to 1 is enabled [when iedir = 1] smi interrupt is requested [setting condition] writing 1 after reading smie3b = 0 interrupt enable direct mode 0 host interrupt is requested when host interrupt enable bit and corresponding obf are both set to 1 1 host interrupt is requested when host interrupt enable bit is set to 1 quiet/continuous mode flag 0 continuous mode [clearing conditions] lpc hardware reset, lpc software reset specification by serirq transfer cycle stop frame 1 quiet mode [setting condition] specification by serirq transfer cycle stop frame reserved
864 sirqcr1?erirq control register 1 h'fe37 hif (lpc) 7 irq11e3 0 r/w 6 irq10e3 0 r/w 5 irq9e3 0 r/w 4 irq6e3 0 r/w 3 irq11e2 0 r/w 0 irq6e2 0 r/w 2 irq10e2 0 r/w 1 irq9e2 0 r/w bit initial value slave read/write host read/write hirq6 interrupt enable 2 0 hirq6 interrupt request by obf2 and irq6e2 is disabled [clearing conditions] writing 0 to irq6e2 lpc hardware reset, lpc software reset clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq6 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq6 interrupt is requested [setting condition] writing 1 after reading irq6e2 = 0 hirq9 interrupt enable 2 0 hirq9 interrupt request by obf2 and irq9e2 is disabled [clearing conditions] writing 0 to irq9e2 lpc hardware reset, lpc software reset clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq9 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq9 interrupt is requested [setting condition] writing 1 after reading irq9e2 = 0 hirq10 interrupt enable 2 0 hirq10 interrupt request by obf2 and irq10e2 is disabled [clearing conditions] writing 0 to irq10e2 lpc hardware reset, lpc software reset clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq10 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq10 interrupt is requested [setting condition] writing 1 after reading irq10e2 = 0 hirq11 interrupt enable 2 0 hirq11 interrupt request by obf2 and irq11e2 is disabled [clearing conditions] writing 0 to irq11e2 lpc hardware reset, lpc software reset clearing obf2 to 0 (when iedir = 0) 1 [when iedir = 0] hirq11 interrupt request by setting obf2 to 1 is enabled [when iedir = 1] hirq11 interrupt is requested [setting condition] ? writing 1 after reading irq11e2 = 0 hirq6 interrupt enable 3 0 hirq6 interrupt request by obf3a and irq6e3 is disabled [clearing conditions] writing 0 to irq6e3 lpc hardware reset, lpc software reset clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq6 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq6 interrupt is requested [setting condition] writing 1 after reading irq6e3 = 0 hirq9 interrupt enable 3 0 hirq9 interrupt request by obf3a and irq9e3 is disabled [clearing conditions] writing 0 to irq9e3 lpc hardware reset, lpc software reset clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq9 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq9 interrupt is requested [setting condition] writing 1 after reading irq9e3 = 0 hirq10 interrupt enable 3 0 hirq10 interrupt request by obf3a and irq10e3 is disabled [clearing conditions] writing 0 to irq10e3 lpc hardware reset, lpc software reset clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq10 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq10 interrupt is requested [setting condition] writing 1 after reading irq10e3 = 0 hirq11 interrupt enable 3 0 hirq11 interrupt request by obf3a and irq11e3 is disabled [clearing conditions] writing 0 to irq11e3 lpc hardware reset, lpc software reset clearing obf3a to 0 (when iedir = 0) 1 [when iedir = 0] hirq11 interrupt request by setting obf3a to 1 is enabled [when iedir = 1] hirq11 interrupt is requested [setting condition] writing 1 after reading irq11e3 = 0
865 hicr0?ost interface control register 0 h'fe40 hif (lpc) 7 lpc3e 0 r/w 6 lpc2e 0 r/w 5 lpc1e 0 r/w 4 fga20e 0 r/w 3 sdwne 0 r/w 0 lscie 0 r/w 2 pmee 0 r/w 1 lsmie 0 r/w bit initial value slave read/write host read/write lsci output enable hicr0 bit 0 hicr1 bit 0 lscib 0 1 0 1 lscie description 0 lsci output disabled, other function of pin enabled lsci output disabled, other function of pin enabled 1 lsci output enabled, lsci pin output goes to 0 level lsci output enabled, lsci pin output is high-impedance lsmi output enable hicr0 bit 1 hicr1 bit 1 lsmib 0 1 0 1 lsmie description 0 lsmi output disabled, other function of pin enabled lsmi output disabled, other function of pin enabled 1 lsmi output enabled, lsmi pin output goes to 0 level lsmi output enabled, lsmi pin output is high-impedance pme output enable hicr0 bit 2 hicr1 bit 2 pmeb 0 1 0 1 pmee description 0 pme output disabled, other function of pin enabled pme output disabled, other function of pin enabled 1 pme output enabled, pme pin output goes to 0 level pme output enabled, pme pin output is high-impedance fast gate a20 enable 0 fast gate a20 function is disabled other function of pin is enabled ga20 output internal state is initialized to 1 1 fast gate a20 function is enabled ga20 pin output is open-drain (external vcc pull-up resistor required) lpc enable 1 0 lpc channel 1 operation is disabled no address (h'0060, 64) matches for idr1, odr1, or str1 1 lpc channel 1 operation is enabled lpc enable 2 0 lpc channel 2 operation is disabled no address (h'0062, 66) matches for idr2, odr2, or str2 1 lpc channel 2 operation is enabled lpc enable 3 0 lpc channel 3 operation is disabled no address (ladr3) matches for idr3, odr3, str3, or twr0 to twr15 1 lpc channel 3 operation is enabled lpc software shutdown enable 0 normal state, lpc software shutdown setting enabled [clearing conditions] writing 0 lpc hardware reset or lpc software reset lpc hardware shutdown release (rising edge of lpcpd signal) 1 lpc hardware shutdown state setting enabled hardware shutdown state when lpcpd signal is low [setting condition] writing 1 after reading sdwne = 0
866 hicr1?ost interface control register 1 h'fe41 hif (lpc) 7 lpcbsy 0 r 6 clkreq 0 r 5 irqbsy 0 r 4 lrstb 0 r/w 3 sdwnb 0 r/w 0 lscib 0 r/w 2 pmeb 0 r/w 1 lsmib 0 r/w bit initial value slave read/write host read/write lsci output bit hicr0 bit 0 hicr1 bit 0 lscib 0 1 0 1 lscie description 0 lsci output disabled, other function of pin enabled lsci output disabled, other function of pin enabled 1 lsci output enabled, lsci pin output goes to 0 level lsci output enabled, lsci pin output is high-impedance lsmi output bit hicr0 bit 1 hicr1 bit 1 lsmib 0 1 0 1 lsmie description 0 lsmi output disabled, other function of pin enabled lsmi output disabled, other function of pin enabled 1 lsmi output enabled, lsmi pin output goes to 0 level lsmi output enabled, lsmi pin output is high-impedance pme output bit hicr0 bit 2 hicr1 bit 2 pmeb 0 1 0 1 pmee description 0 pme output disabled, other function of pin enabled pme output disabled, other function of pin enabled 1 pme output enabled, pme pin output goes to 0 level pme output enabled, pme pin output is high-impedance lpc software shutdown bit 0 normal state [clearing conditions] writing 0 lpc hardware reset or lpc software reset lpc hardware shutdown (falling edge of lpcpd signal when sdwne = 1) lpc hardware shutdown release (rising edge of lpcpd signal when sdwne = 0) 1 lpc software shutdown state [setting condition] writing 1 after reading sdwnb = 0 lpc software reset bit 0 normal state [clearing conditions] writing 0 lpc hardware reset 1 lpc software reset state [setting condition] writing 1 after reading lrstb = 0 serirq busy 0 serirq transfer frame wait state [clearing conditions] lpc hardware reset or lpc software reset lpc hardware shutdown or lpc software shutdown end of serirq transfer frame 1 serirq transfer processing in progress [setting condition] start of serirq transfer frame lclk request 0 no lclk restart request [clearing conditions] lpc hardware reset or lpc software reset lpc hardware shutdown or lpc software shutdown serirq is set to continuous mode there are no further interrupts for transfer to the host in quiet mode 1 lclk restart request issued [setting condition] in quiet mode, serirq interrupt output becomes necessary while lclk is stopped lpc busy 0 host interface is in transfer cycle wait state bus idle, or transfer cycle not subject to processing is in progress cycle type or address indeterminate during transfer cycle [clearing conditions] lpc hardware reset or lpc software reset lpc hardware shutdown or lpc software shutdown forced termination (abort) of transfer cycle subject to processing normal termination of transfer cycle subject to processing 1 host interface is performing transfer cycle processing [setting condition] match of cycle type and address
867 hicr2?ost interface control register 2 h'fe42 hif (lpc) 7 ga20 0 r 6 lrst 0 r/(w) * 5 sdwn 0 r/(w) * 4 abrt 0 r/(w) * 3 ibfie3 0 r/w 0 errie 0 r/w 2 ibfie2 0 r/w 1 ibfie1 0 r/w bit initial value slave read/write host read/write input data register full interrupt enable 3 to 1/error interrupt enable ibfie3 ibfie2 ibfie1 erri description 0 error interrupt requests disabled 1 error interrupt requests enabled 0 input data register idr1 receive-complete interrupt request disabled 1 input data register idr1 receive-complete interrupt request enabled 0 input data register idr2 receive-complete interrupt request disabled 1 input data register idr2 receive-complete interrupt request enabled 0 input data register idr3 and twr receive-complete interrupt requests disabled 1 input data register idr3 and twr receive-complete interrupt requests enabled lpc above interrupt flag 0 [clearing conditions] writing 0 after reading abrt = 1 lpc hardware reset ( lreset pin falling edge detection) lpc software reset (lrstb = 1) lpc hardware shutdown (sdwne = 1 and lpcpd falling edge detection) lpc software shutdown (sdwnb = 1) 1 [setting condition] lframe pin falling edge detection during lpc transfer cycle lpc shutdown interrupt flag note: * only 0 can be written to bits 6 to 4, to clear the flags. 0 [clearing conditions] writing 0 after reading sdwn = 1 lpc hardware reset ( lreset pin falling edge detection) lpc software reset (lrstb = 1) 1 [setting condition] lpcpd pin falling edge detection lpc reset interrupt flag 0 [clearing condition] writing 0 after reading lrst = 1 1 [setting condition] lreset pin falling edge detection ga20 pin monitor 0 ga20 pin goes to low level 1 ga20 pin goes to high level
868 hicr3?ost interface control register 3 h'fe43 hif (lpc) 7 lframe 0 r 6 clkrun 0 r 5 serirq 0 r 4 lreset 0 r 3 lpcpd 0 r 0 lsci 0 r 2 pme 0 r 1 lsmi 0 r bit initial value slave read/write host read/write lsci pin monitor 0 lsci pin goes to low level 1 lsci pin goes to high level pme pin monitor 0 pme pin goes to low level 1 pme pin goes to high level lpcpd pin monitor 0 lpcpd pin goes to low level 1 lpcpd pin goes to high level lreset pin monitor 0 lreset pin goes to low level 1 lreset pin goes to high level clkrun pin monitor 0 clkrun pin goes to low level 1 clkrun pin goes to high level lframe pin monitor 0 lframe pin goes to low level 1 lframe pin goes to high level serirq pin monitor 0 serirq pin goes to low level 1 serirq pin goes to high level lsmi pin monitor 0 lsmi pin goes to low level 1 lsmi pin goes to high level
869 wuemrb?akeup event interrupt mask register b h'fe44 interrupt controller wakeup event interrupt mask 0 wakeup event interrupt request enabled 1 wakeup event interrupt request disabled 7 wuemr7 1 r/w 6 wuemr6 1 r/w 5 wuemr5 1 r/w 4 wuemr4 1 r/w 3 wuemr3 1 r/w 0 wuemr0 1 r/w 2 wuemr2 1 r/w 1 wuemr1 1 r/w bit initial value read/write hicr2?ost interface control register 2 h'fe80 hif (xbs) 7 1 6 1 5 1 4 1 3 1 0 0 2 ibfie4 0 r/w 1 ibfie3 0 r/w bit initial value slave read/write host read/write input data register full interrupt enable bit 3 0 input data register (idr3) reception completed interrupt request disabled 1 input data register (idr3) reception completed interrupt request enabled input data register full interrupt enable bit 4 0 input data register (idr4) reception completed interrupt request disabled 1 input data register (idr4) reception completed interrupt request enabled
870 idr3?nput data register 3 h'fe84 hif (xbs) idr4?nput data register 4 h'fe8c hif (xbs) 7 idr7 r w 6 idr6 r w 5 idr5 r w 4 idr4 r w 3 idr3 r w 0 idr0 r w 2 idr2 r w 1 idr1 r w bit initial value slave r/w host r/w stores host data bus contents at rise of iow when cs is low odr3?utput data register 3 h'fe85 hif (xbs) odr4?utput data register 4 h'fe8d hif (xbs) 7 odr7 r/w r 6 odr6 r/w r 5 odr5 r/w r 4 odr4 r/w r 3 odr3 r/w r 0 odr0 r/w r 2 odr2 r/w r 1 odr1 r/w r bit initial value slave r/w host r/w odr contents are output to the host data bus when ha0 is low, cs is low, and ior is low
871 str3?tatus register 3 h'fe86 hif (xbs) str4?tatus register 4 h'fe8e hif (xbs) 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r/(w) * r 2 dbu 0 r/w r 1 ibf 0 r r bit initial value slave r/w host r/w output buffer full 0 [clearing condition] when the host processor reads odr or the slave writes 0 in the obf bit 1 [setting condition] when the slave processor writes to odr user-defined bits input buffer full 0 [clearing condition] when the slave processor reads idr 1 [setting condition] when the host processor writes to idr command/data 0 contents of input data register (idr) are data 1 contents of input data register (idr) are a command note: * onl y 0 can be written, to clear the fla g .
872 kbcrh0?eyboard control register h0 h'fed8 keyboard buffer controller kbcrh1?eyboard control register h1 h'fedc keyboard buffer controller kbcrh2?eyboard control register h2 h'fee0 keyboard buffer controller kbioe kbf per kbs kclki kdi kbfsel kbie bit initial value read/write 7654321 0 0 1110000 r/w r/(w) * r/(w) * r r r r/w r/w keyboard stop 0 ? stop bit received 1 ? stop bit received note: * only 0 can be written, to clear the flag. parity error 0 [clearing condition] read per when per =1, then write 0 in per 1 [setting condition] when an odd parity error occurs keyboard buffer register full 0 [clearing condition] read kbf when kbf =1, then write 0 in kbf 1 keyboard interrupt enable 0 interrupt requests are disabled 1 interrupt requests are enabled keyboard buffer register full select 0 kbf bit is used as kclk fall interrupt flag 1 kbf bit is used as keyboard buffer register full flag keyboard data in 0 kd i/o pin is low 1 kd i/o pin is high keyboard clock in 0 kclk i/o pin is low 1 kclk i/o pin is high keyboard in/out enable 0 the keyboard buffer controller is non-operational (kclk and kd signal pins have port functions) 1 the keyboard buffer controller is enabled for transmission and reception (kclk and kd signal pins are in the bus drive state) [setting conditions] ? when data has been received normally while kbfsel = 1, and has been transferred to kbbr (keyboard buffer register full flag) ? when a kclk falling edge has been detected while kbfsel = 0 (kclk interrupt flag)
873 kbcrl0?eyboard control register l0 h'fed9 keyboard buffer controller kbcrl1?eyboard control register l1 h'fedd keyboard buffer controller kbcrl2?eyboard control register l2 h'fee1 keyboard buffer controller kbe rxcr2 rxcr1 rxcr0 kclko kdo rxcr3 bit initial value read/write 7654321 0 0 1110000 r/w r r r r/w r/w r receive counter rxcr2 rxcr1 0 1 0 1 0 1 0 1 0 1 rxcr0 0 1 0 1 0 1 0 1 0 1 0 1 rxcr3 0 1 receive data contents start bit kb0 kb1 kb2 kb3 kb4 kb5 kb6 kb7 parity bit keyboard data out 0 keyboard buffer controller data i/o pin is low 1 keyboard buffer controller data i/o pin is high keyboard clock out 0 keyboard buffer controller clock i/o pin is low 1 keyboard buffer controller clock i/o pin is high keyboard enable 0 loading of receive data into kbbr is disabled 1 loading of receive data into kbbr is enabled
874 kbbr0?eyboard data buffer register 0 h'feda keyboard buffer controller kbbr1?eyboard data buffer register 1 h'fede keyboard buffer controller kbbr2?eyboard data buffer register 2 h'fee2 keyboard buffer controller kb7 kb2 kb1 kb0 kb6 kb5 kb4 kb3 bit initial value read/write 7654321 0 0 0000000 rrrr rrrr stores receive data
875 kbcomp?eyboard comparator control register h'fee4 irda/expansion a/d 7 ire 0 r/w 6 ircks2 0 r/w 5 ircks1 0 r/w 4 ircks0 0 r/w 3 kbade 0 r/w 0 kbch0 0 r/w 2 kbch2 0 r/w 1 kbch1 0 r/w bit initial value read/write an6 cin0 cin1 cin2 cin3 cin4 cin5 cin6 cin7 an7 cin8 cin9 cin10 cin11 cin12 cin13 cin14 cin15 bit 3: keyboard a/d enable bits 2 to 0: keyboard a/d channel select 2 to 0 bit 3 kbade 0 1 a/d converter channel 6 input a/d converter channel 7 input bit 2 kbch2 0 1 bit 1 kbch1 0 1 0 1 bit 0 kbch0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 b 3/16 (3/16 of the bit rate) ?2 ?4 ?8 ?16 ?32 ?64 ?128 irda clock select 2 to 0 irda enable 0 the txd2/irtxd and rxd2/irrxd pins function as txd2 and rxd2 1 the txd2/irtxd and rxd2/irrxd pins function as irtxd and irrxd
876 ddcswr?dc switch register h'fee6 iic0 7 swe 0 r/w 6 sw 0 r/w 5 ie 0 r/w 4 if 0 r/(w) * 1 3 clr3 1 w * 2 0 clr0 1 w * 2 2 clr2 1 w * 2 1 clr1 1 w * 2 bit initial value read/write ddc mode switch interrupt flag 0 no interrupt is requested when automatic format switching is executed [clearing condition] when 0 is written in if after reading if = 1 1 an interrupt is requested when automatic format switching is executed [setting condition] when a falling edge is detected on the scl pin when swe = 1 ddc mode switch interrupt enable bit 0 interrupt when automatic format switching is executed is disabled 1 interrupt when automatic format switching is executed is enabled ddc mode switch 0 iic channel 0 is used with the i 2 c bus format [clearing conditions] ? when 0 is written by software ? when a falling edge is detected on the scl pin when swe = 1 1 iic channel 0 is used in formatless mode [setting condition] when 1 is written in sw after reading sw = 0 ddc mode switch enable 0 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is disabled 1 automatic switching of iic channel 0 from formatless mode to i 2 c bus format is enabled iic clear bits bit 3 clr3 0 1 description setting prohibited setting prohibited iic0 internal latch cleared iic1 internal latch cleared iic0 and iic1 internal latches cleared invalid setting bit 2 clr2 0 1 bit 1 clr1 0 1 bit 0 clr0 0 1 0 1 notes: 1. only 0 can be written, to clear the flag. 2. always read as 1.
877 icra?nterrupt control register a h'fee8 interrupt controller icrb?nterrupt control register b h'fee9 interrupt controller icrc?nterrupt control register c h'feea interrupt controller 7 icr7 0 r/w 6 icr6 0 r/w 5 icr5 0 r/w 4 icr4 0 r/w 3 icr3 0 r/w 0 icr0 0 r/w 2 icr2 0 r/w 1 icr1 0 r/w bit initial value read/write interrupt control level 0 corresponding interrupt source is control level 0 (non-priority) 1 corresponding interrupt source is control level 1 (priority) correspondence between interrupt sources and icr settings register bits 76543210 icra irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq7 dtc watchdog timer 0 watchdog timer 1 icrb a/d converter free- running timer 8-bit timer channel 0 8-bit timer channel 1 8-bit timer channels x, y hif:xbs, keyboard buffer controller icrc sci channel 0 sci channel 1 sci channel 2 iic channel 0 iic channel 1 hif:lpc
878 isr?rq status register h'feeb interrupt controller 7 irq7f 0 r/(w) * 1 6 irq6f 0 r/(w) * 1 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 irq3f 0 r/(w) * 0 irq0f 0 r/(w) * 2 irq2f 0 r/(w) * 1 irq1f 0 r/(w) * bit initial value read/write irq7 to irq0 flags 0 [clearing conditions] ? cleared by reading irqnf when set to 1, then writing 0 in irqnf ? when interrupt exception handling is executed while low-level detection is set (irqnscb = irqnsca = 0) and irqn input is high * 2 ? when irqn interrupt exception handling is executed while falling, rising, or both-edge detection is set (irqnscb = 1 or irqnsca = 1) * 2 1 [setting conditions] ? when irqn input goes low when low-level detection is set (irqnscb = irqnsca = 0) ? when a falling edge occurs in irqn input while falling edge detection is set (irqnscb = 0, irqnsca = 1) ? when a rising edge occurs in irqn input while rising edge detection is set (irqnscb = 1, irqnsca = 0) ? when a falling or rising edge occurs in irqn input while both-edge detection is set (irqnscb = irqnsca = 1) notes: 1. only 0 can be written, to clear the flag. (n = 7 to 0) 2. when a product, in which a dtc is incorporated, is used in the following settings, the corresponding flag bit is not automatically cleared even when exception handing, which is a clear condition, is executed and the bit is held at 1. (1) when dtcea3 is set to 1 (adi is set to an interrupt source), irq4f flag is not automatically cleared. (2) when dtcea2 is set to 1 (icia is set to an interrupt source), irq5f flag is not automatically cleared. (3) when dtcea1 is set to 1 (icib is set to an interrupt source), irq6f flag is not automatically cleared. (4) when dtcea0 is set to 1 (ocia is set to an interrupt source), irq7f flag is not automatically cleared. when activation interrupt sources of dtc and irq interrupts are used with the above combinations, clear the interrupt flag by software in the interrupt handling routine of the corresponding irq.
879 iscrh?rq sense control register h h'feec interrupt controller iscrl?rq sense control register l h'feed interrupt controller 15 irq7scb 0 r/w 14 irq7sca 0 r/w 13 irq6scb 0 r/w 12 irq6sca 0 r/w 11 irq5scb 0 r/w 8 irq4sca 0 r/w 10 irq5sca 0 r/w 9 irq4scb 0 r/w bit initial value read/write iscrh 7 irq3scb 0 r/w 6 irq3sca 0 r/w 5 irq2scb 0 r/w 4 irq2sca 0 r/w 3 irq1scb 0 r/w 0 irq0sca 0 r/w 2 irq1sca 0 r/w 1 irq0scb 0 r/w bit initial value read/write iscrl irq7 to irq4 sense control a and b irq3 to irq0 sense control a and b description iscrh bits 7 to 0 iscrl bits 7 to 0 irq7scb to irq0scb irq7sca to irq0sca 0 1 0 1 0 1 interrupt request generated at irq7 to irq0 input at low level interrupt request generated at falling edge of irq7 to irq0 input interrupt request generated at rising edge of irq7 to irq0 input interrupt request generated at both falling and rising edges of irq7 to irq0 input
880 dtcer?tc enable register h'feee to h'fef2 dtc 7 dtce7 0 r/w 6 dtce6 0 r/w 5 dtce5 0 r/w 4 dtce4 0 r/w 3 dtce3 0 r/w 0 dtce0 0 r/w 2 dtce2 0 r/w 1 dtce1 0 r/w bit initial value read/write dtc activation enable 0 dtc activation by interrupt is disabled [clearing conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end 1 dtc activation by interrupt is enabled [holding condition] when the disel bit is 0 and the specified number of transfers have not ended dtvecr?tc vector register h'fef3 dtc 7 swdte 0 r/(w) * 6 dtvec6 0 r/w 5 dtvec5 0 r/w 4 dtvec4 0 r/w 3 dtvec3 0 r/w 0 dtvec0 0 r/w 2 dtvec2 0 r/w 1 dtvec1 0 r/w bit initial value read/write note: * sets vector number for dtc software activation dtc software activation enable 0 dtc software activation is disabled [clearing condition] when the disel bit is 0 and the specified number of transfers have not ended 1 dtc software activation is enabled [holding conditions] ? when data transfer ends with the disel bit set to 1 ? when the specified number of transfers end ? during software-activated deta transfer a value of 1 can always be written to the swdte bit, but 0 can only be written after 1 is read.
881 abrkcr?ddress break control register h'fef4 interrupt controller 7 cmf 0 r 6 0 5 0 4 0 3 0 0 bie 0 r/w 2 0 1 0 bit initial value read/write break interrupt enable 0 address break disabled 1 address break enabled condition match flag 0 [clearing condition] when address break interrupt exception handling is executed 1 [setting condition] when address set by bara to barc is prefetched while bie = 1
882 bara?reak address register a h'fef5 interrupt controller barb?reak address register b h'fef6 interrupt controller barc?reak address register c h'fef7 interrupt controller 7 a23 0 r/w 6 a22 0 r/w 5 a21 0 r/w 4 a20 0 r/w 3 a19 0 r/w 0 a16 0 r/w 2 a18 0 r/w 1 a17 0 r/w bit bara initial value read/write 7 a15 0 r/w 6 a14 0 r/w 5 a13 0 r/w 4 a12 0 r/w 3 a11 0 r/w 0 a8 0 r/w 2 a10 0 r/w 1 a9 0 r/w bit barb initial value read/write 7 a7 0 r/w 6 a6 0 r/w 5 a5 0 r/w 4 a4 0 r/w 3 a3 0 r/w 0 0 2 a2 0 r/w 1 a1 0 r/w bit barc initial value read/write specifies address (bits 23 to 16) at which address break is to be generated specifies address (bits 15 to 8) at which address break is to be generated specifies address (bits 7 to 1) at which address break is to be generated
883 flmcr1?lash memory control register 1 h'ff80 flash memory 7 fwe 1 r 6 swe 0 r/w 5 0 4 0 3 ev 0 r/w 0 p 0 r/w 2 pv 0 r/w 1 e 0 r/w bit initial value read/write program 0 program mode cleared 1 transition to program mode [setting condition] when swe = 1, and psu = 1 erase 0 erase mode cleared 1 transition to erase mode [setting condition] when swe = 1, and esu = 1 program-verify 0 program-verify mode cleared 1 transition to program-verify mode [setting condition] when swe = 1 erase-verify 0 erase-verify mode cleared 1 transition to erase-verify mode [setting condition] when swe = 1 software write enable 0 writes disabled 1 writes enabled flash write enable
884 flmcr2?lash memory control register 2 h'ff81 flash memory 7 fler 0 r 6 0 5 0 4 0 3 0 0 psu 0 r/w 2 0 1 esu 0 r/w bit initial value read/write program setup 0 program setup cleared 1 program setup [setting condition] when swe = 1 erase setup 0 erase setup cleared 1 erase setup [setting condition] when swe = 1 flash memory error 0 flash memory is operating normally flash memory program/erase protection (error protection) is disabled [clearing condition] reset or hardware standby mode 1 an error has occurred during flash memory programming/erasing flash memory program/erase protection (error protection) is enabled [setting condition] see section 22.8.3, error protection
885 pcsr?eripheral clock select register h'ff82 pwm 7 0 6 0 5 0 4 0 3 0 0 0 2 pwckb 0 r/w 1 pwcka 0 r/w bit initial value read/write pwm clock select pwsl pcsr bit 7 pwcke 0 1 bit 6 pwcks 0 1 bit 2 pwckb 0 1 bit 1 pwcka 0 1 0 1 clock input is disabled ?(system clock) is selected ?2 is selected ?4 is selected ?8 is selected ?16 is selected description
886 syscr2?ystem control register 2 h'ff83 hif (xbs) 7 kwul1 0 r/w 6 kwul0 0 r/w 5 p6pue 0 r/w 4 0 3 sde 0 r/w 0 hi12e 0 r/w 2 cs4e 0 r/w 1 cs3e 0 r/w bit initial value read/write host interface enable 0 host interface functions are disabled 1 host interface functions are enabled shutdown enable 0 host interface pin shutdown function disabled 1 host interface pin shutdown function enabled cs4 enable 0 host interface pin channel 4 functions disabled 1 host interface pin channel 4 functions enabled cs3 enable 0 host interface pin channel 3 functions disabled 1 host interface pin channel 3 functions enabled port 6 mos input pull-up extra 0 standard current specification is selected for port 6 mos input pull-up function 1 current-limit specification is selected for port 6 mos input pull-up function key wakeup level 1 and 0 0 standard input level is selected as port 6 input level input level 1 is selected as port 6 input level input level 2 is selected as port 6 input level input level 3 is selected as port 6 input level 0 1 10 1
887 ebr1?rase block register 1 h'ff82 flash memory ebr2?rase block register 2 h'ff83 flash memory 7 0 * 2 6 0 * 2 5 0 * 2 4 0 * 2 3 0 * 2 0 0 * 2 2 0 * 2 1 0 * 2 bit initial value read/write 7 eb7 0 r/w * 1 6 eb6 0 r/w 5 eb5 0 r/w 4 eb4 0 r/w 3 eb3 0 r/w 0 eb0 0 r/w 2 eb2 0 r/w 1 eb1 0 r/w bit initial value read/write block (size) erase blocks eb0 (1 kbyte) eb1 (1 kbyte) eb2 (1 kbyte) eb3 (1 kbyte) eb4 (28 kbytes) eb5 (16 kbytes) eb6 (8 kbytes) eb7 (8 kbytes) addresses h'(00)0000 to h'(00)03ff h'(00)0400 to h'(00)07ff h'(00)0800 to h'(00)0bff h'(00)0c00 to h'(00)0fff h'(00)1000 to h'(00)7fff h'(00)8000 to h'(00)bfff h'(00)c000 to h'(00)dfff h'00e000 to h'00ffff notes: 1. in normal mode, these bits cannot be modified and are always read as 0. 2. this bit must not be set to 1.
888 sbycr?tandby control register h'ff84 system 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 0 0 sck0 0 r/w 2 sck2 0 r/w 1 sck1 0 r/w bit initial value read/write 0 1 0 1 0 1 0 1 0 1 bus master is in high-speed mode medium-speed clock = ?2 medium-speed clock = ?4 medium-speed clock = ?8 medium-speed clock = ?16 medium-speed clock = ?32 0 1 system clock select 2 to 0 0 1 0 1 0 1 0 1 0 1 0 1 standby time = 8192 states standby time = 16384 states standby time = 32768 states standby time = 65536 states standby time = 131072 states standby time = 262144 states reserved standby time = 16 states * 0 1 standby timer select 2 to 0 software standby 0 transition to sleep mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to subsleep mode on execution of sleep instruction in subactive mode 1 transition to software standby mode, subactive mode, or watch mode after execution of sleep instruction in high-speed mode or medium-speed mode transition to watch mode or high-speed mode after execution of sleep instruction in subactive mode note: * this setting must not be used in the flash memory version.
889 lpwrcr?ow-power control register h'ff85 system 7 dton 0 r/w r/w 6 lson 0 r/w r/w 5 nesel 0 r/w r/w 4 excle 0 r/w r/w 3 0 r/w 0 0 2 0 1 0 bit initial value read/write (8s/2169) read/write (8s/2149) subclock input enable 0 subclock input from excl pin is disabled 1 subclock input from excl pin is enabled noise elimination sampling frequency select 0 sampling at ?divided by 32 1 sampling at ?divided by 4 low-speed on flag 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * ? when a sleep instruction is executed in subactive mode, a transition is made to watch mode, or directly to high-speed mode ? after watch mode is cleared, a transition is made to high-speed mode 1 when a sleep instruction is executed in high-speed mode a transition is made to watch mode or subactive mode * ? when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode ? after watch mode is cleared, a transition is made to subactive mode direct-transfer on flag 0 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made to sleep mode, software standby mode, or watch mode * ? when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode or watch mode 1 when a sleep instruction is executed in high-speed mode or medium-speed mode, a transition is made directly to subactive mode * , or a transition is made to sleep mode or software standby mode ? when a sleep instruction is executed in subactive mode, a transition is made directly to high-speed mode, or a transition is made to subsleep mode note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set. note: * when a transition is made to watch mode or subactive mode, high-speed mode must be set.
890 mstpcrh?odule stop control register h h'ff86 system mstpcrl?odule stop control register l h'ff87 system 7 mstp15 0 r/w bit initial value read/write 6 mstp14 0 r/w 5 mstp13 1 r/w 4 mstp12 1 r/w 3 mstp11 1 r/w 2 mstp10 1 r/w 1 mstp9 1 r/w 0 mstp8 1 r/w 7 mstp7 1 r/w 6 mstp6 1 r/w 5 mstp5 1 r/w 4 mstp4 1 r/w 3 mstp3 1 r/w 2 mstp2 1 r/w 1 mstp1 1 r/w 0 mstp0 1 r/w mstpcrh mstpcrl module stop 0 module stop mode is cleared 1 module stop mode is set mstp15 * mstp14 mstp13 mstp12 mstp11 mstp10 mstp9 mstp8 mstp7 mstp6 mstp5 mstp4 mstp3 mstp2 mstp1 mstp0 data transfer controller (dtc) 16-bit free-running timer (frt) 8-bit timers (tmr0, tmr1) 8-bit pwm timer (pwm), 14-bit pwm timer (pwmx) d/a converter a/d converter 8-bit timers (tmrx, tmry), timer connection serial communication interface 0 (sci0) serial communication interface 1 (sci1) serial communication interface 2 (sci2) i 2 c bus interface (iic) channel 0 i 2 c bus interface (iic) channel 1 host interface (hif:xbs), keyboard matrix interrupt mask register (kmimr), keyboard matrix interrupt mask register a (kmimra), port 6 mos pull-up control register (kmpcr), keyboard buffer controller (ps2) host interface (hif:lpc) mstpcrh mstpcrl register bit module the correspondence between mstpcr bits and on-chip supporting modules is shown below. notes: bits 1 and 0 can be read and written but do not affect operation. * bit 15 must not be set to 1.
891 smr1?erial mode register 1 h'ff88 sci1 smr2?erial mode register 2 h'ffa0 sci2 smr0?erial mode register 0 h'ffd8 sci0 7 c/ a 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 o/ e 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w bit initial value read/write clock select 1 and 0 0 clock ?4 clock ?16 clock ?64 clock 0 1 10 1 stop bit length 0 1 stop bit 2 stop bits 1 multiprocessor mode 0 multiprocessor function disabled 1 multiprocessor format selected parity mode 0 even parity odd parity 1 parity enable 0 parity bit addition and checking disabled parity bit addition and checking enabled 1 character length 0 8-bit data 7-bit data * 1 note: * when 7-bit data is selected, the msb (bit 7) of tdr is not transmitted. also, lsb-first/ msb-first selection is not available. communication mode 0 asynchronous mode synchronous mode 1
892 iccr1? 2 c bus control register 1 h'ff88 iic1 iccr0? 2 c bus control register 0 h'ffd8 iic0 7 ice 0 r/w 6 ieic 0 r/w 5 mst 0 r/w 4 trs 0 r/w 3 acke 0 r/w 0 scp 1 w 2 bbsy 0 r/w 1 iric 0 r/(w) * bit initial value read/write start condition/stop condition prohibit 0 writing 0 issues a start or stop condition, in combination with the bbsy flag 1 reading always returns a value of 1; writing is ignored i 2 c bus interface interrupt request flag 0 waiting for transfer, or transfer in progress 1 interrupt requested note: for the clearing and setting conditions, see section 16.2.5, i 2 c bus control register (iccr). bus busy 0 bus is free [clearing condition] when a stop condition is detected 1 bus is busy [setting condition] when a start condition is detected acknowledge bit judgement selection 0 the value of the acknowledge bit is ignored, and continuous transfer is performed 1 if the acknowledge bit is 1, continuous transfer is interrupted master/slave select (mst), transmit/receive select (trs) 0 slave receive mode slave transmit mode master receive mode master transmit mode 0 1 10 1 i 2 c bus interface interrupt enable 0 interrupts disabled 1 interrupts enabled note: for details, see section 16.2.5, i 2 c bus control register (iccr). i 2 c bus interface enable 0 i 2 c bus interface module disabled, with scl and sda signal pins set to port function i 2 c bus interface module internal state initialized sar and sarx can be accessed 1 i 2 c bus interface module enabled for transfer operations (pins scl and sca are driving the bus) icmr and icdr can be accessed note: * only 0 can be written, to clear the flag.
893 brr1?it rate register 1 h'ff89 sci1 brr2?it rate register 2 h'ffa1 sci2 brr0?it rate register 0 h'ffd9 sci0 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write sets the serial transmit/receive bit rate
894 icsr1? 2 c bus status register 1 h'ff89 iic1 icsr0? 2 c bus status register 0 h'ffd9 iic0 7 estp 0 r/(w) * 1 6 stop 0 r/(w) * 1 5 irtr 0 r/(w) * 1 4 aasx 0 r/(w) * 1 3 al 0 r/(w) * 1 0 ackb 0 r/w 2 aas 0 r/(w) * 1 1 adz 0 r/(w) * 1 bit initial value read/write acknowledge bit 0 receive mode: 0 is output at acknowledge output timing transmit mode: indicates that the receiving device has acknowledged the data (signal is 0) 1 receive mode: 1 is output at acknowledge output timing transmit mode: indicates that the receiving device has not acknowledged the data (signal is 1) notes: general call address recognition flag * 2 0 general call address not recognized 1 general call address recognized slave address recognition flag * 2 0 slave address or general call address not recognized 1 slave address or general call address recognized arbitration lost * 2 0 bus arbitration won 1 arbitration lost second slave address recognition flag * 2 0 second slave address not recognized 1 second slave address recognized i 2 c bus interface continuous transmission/reception interrupt request flag * 2 0 waiting for transfer, or transfer in progress 1 continuous transfer state normal stop condition detection flag * 2 0 no normal stop condition 1 in i 2 c bus format slave mode: normal stop condition detected in other modes: no meaning error stop condition detection flag * 2 0 no error stop condition 1 in i 2 c bus format slave mode: error stop condition detected in other modes: no meaning 1. only 0 can be written, to clear the flag. 2. for the clearin g and settin g conditions, see section 16.2.6, i 2 c bus status re g ister (icsr).
895 scr1?erial control register 1 h'ff8a sci1 scr2?erial control register 2 h'ffa2 sci2 scr0?erial control register 0 h'ffda sci0 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w bit initial value read/write clock enable 1 and 0 0 asynchronous mode synchronous mode 0 asynchronous mode 1 synchronous mode 1 asynchronous mode 0 synchronous mode asynchronous mode 1 synchronous mode internal clock/sck pin functions as i/o port internal clock/sck pin functions as serial clock output internal clock/sck pin functions as clock output internal clock/sck pin functions as serial clock output external clock/sck pin functions as clock input external clock/sck pin functions as serial clock input external clock/sck pin functions as clock input external clock/sck pin functions as serial clock input transmit end interrupt enable 0 transmit-end interrupt (tei) request disabled 1 transmit-end interrupt (tei) request enabled multiprocessor interrupt enable 0 multiprocessor interrupts disabled (normal reception mode) [clearing conditions] ? when the mpie bit is cleared to 0 ? when data with mpb = 1 is received 1 multiprocessor interrupts enabled receive interrupt (rxi) requests, receive-error interrupt (eri) requests, and setting of the rdrf, fer, and orer flags in ssr are disabled until data with the multiprocessor bit set to 1 is received receive enable 0 reception disabled 1 reception enabled transmit enable 0 transmission disabled 1 transmission enabled receive interrupt enable 0 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request disabled 1 receive-data-full interrupt (rxi) request and receive-error interrupt (eri) request enabled transmit interrupt enable 0 transmit-data-empty interrupt (txi) request disabled 1 transmit-data-empty interrupt (txi) request enabled
896 rdr1?eceive data register 1 h'ff8d sci1 rdr2?eceive data register 2 h'ffa5 sci2 rdr0?eceive data register 0 h'ffdd sci0 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write stores serial receive data tdr1?ransmit data register 1 h'ff8b sci1 tdr2?ransmit data register 2 h'ffa3 sci2 tdr0?ransmit data register 0 h'ffdb sci0 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write stores serial transmit data
897 ssr1?erial status register 1 h'ff8c sci1 ssr2?erial status register 2 h'ffa4 sci2 ssr0?erial status register 0 h'ffdc sci0 7 tdre 1 r/(w) * 6 rdrf 0 r/(w) * 5 orer 0 r/(w) * 4 fer 0 r/(w) * 3 per 0 r/(w) * 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r bit initial value read/write multiprocessor bit transfer 0 data with a 0 multi-processor bit is transmitted 1 data with a 1 multi-processor bit is transmitted note: * only 0 can be written, to clear the flag. multiprocessor bit 0 [clearing condition] when data with a 0 multiprocessor bit is received 1 [setting condition] when data with a 1 multiprocessor bit is received transmit end 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] ? when the te bit in scr is 0 ? when tdre = 1 at transmission of the last bit of a 1-byte serial transmit character parity error 0 [clearing condition] when 0 is written in per after reading per = 1 1 [setting condition] when, in reception, the number of 1 bits in the receive data plus the parity bit does not match the parity setting (even or odd) specified by the o/ e bit in smr framing error 0 [clearing condition] when 0 is written in fer after reading fer = 1 1 [setting condition] when the sci checks the stop bit at the end of the receive data when reception ends, and the stop bit is 0 overrun error 0 [clearing condition] when 0 is written in orer after reading orer = 1 1 [setting condition] when the next serial reception is completed while rdrf = 1 receive data register full 0 [clearing conditions] ? when 0 is written in rdrf after reading rdrf = 1 ? when the dtc is activated by an rxi interrupt and reads data from rdr 1 [setting condition] when serial reception ends normally and receive data is transferred from rsr to rdr transmit data register empty 0 [clearing conditions] ? when 0 is written in tdre after reading tdre = 1 ? when the dtc is activated by a txi interrupt and writes data to tdr 1 [setting conditions] ? when the te bit in scr is 0 ? when data is transferred from tdr to tsr and data can be written in tdr
898 scmr1?erial interface mode register 1 h'ff8e sci1 scmr2?erial interface mode register 2 h'ffa6 sci2 scmr0?erial interface mode register 0 h'ffde sci0 7 1 6 1 5 1 4 1 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 1 bit initial value read/write serial communication interface mode select 0 normal sci mode 1 reserved mode data invert 0 tdr contents are transmitted without modification receive data is stored in rdr without modification 1 tdr contents are inverted before being transmitted receive data is stored in rdr in inverted form data transfer direction 0 tdr contents are transmitted lsb-first receive data is stored in rdr lsb-first 1 tdr contents are transmitted msb-first receive data is stored in rdr msb-first
899 icdr1? 2 c bus data register 1 h'ff8e iic1 icdr0? 2 c bus data register 0 h'ffde iic0 7 icdr7 r/w 6 icdr6 r/w 5 icdr5 r/w 4 icdr4 r/w 3 icdr3 r/w 0 icdr0 r/w 2 icdr2 r/w 1 icdr1 r/w bit initial value read/write 7 icdrr7 r 6 icdrr6 r 5 icdrr5 r 4 icdrr4 r 3 icdrr3 r 0 icdrr0 r 2 icdrr2 r 1 icdrr1 r bit initial value read/write icdrr icdrs 7 icdrs7 6 icdrs6 5 icdrs5 4 icdrs4 3 icdrs3 0 icdrs0 2 icdrs2 1 icdrs1 bit initial value read/write icdrt 7 icdrt7 w 6 icdrt6 w 5 icdrt5 w 4 icdrt4 w 3 icdrt3 w 0 icdrt0 w 2 icdrt2 w 1 icdrt1 w bit initial value read/write tdre, rdrf (internal flags) rdrf 0 tdre 0 bit initial value read/write note: for details, see section 16.2.1, i 2 c bus data register (icdr).
900 sarx1?econd slave address register 1 h'ff8e iic1 sar1?lave address register 1 h'ff8f iic1 sarx0?econd slave address register 0 h'ffde iic0 sar0?lave address register 0 h'ffdf iic0 7 sva6 0 r/w 6 sva5 0 r/w 5 sva4 0 r/w 4 sva3 0 r/w 3 sva2 0 r/w 0 fs 0 r/w 2 sva1 0 r/w 1 sva0 0 r/w bit initial value read/write sar sarx slave address format select second slave address 7 svax6 0 r/w 6 svax5 0 r/w 5 svax4 0 r/w 4 svax3 0 r/w 3 svax2 0 r/w 0 fsx 1 r/w 2 svax1 0 r/w 1 svax0 0 r/w bit initial value read/write note: * format select ddcswr bit 6 sw sar bit 0 fs sarx bit 0 fsx operating mode i 2 c bus format ? sar and sarx slave addresses recognized 0 00 i 2 c bus format ? sar slave address recognized ? sarx slave address ignored i 2 c bus format ? sar slave address ignored ? sarx slave address recognized synchronous serial format ? sar and sarx slave addresses ignored formatless mode (start/stop conditions not detected) ? acknowledge bit used formatless mode * (start/stop conditions not detected) ?no acknowledge bit 1 10 1 100 1 10 1 do not set this mode when automatic switching to the i 2 c bus format is performed by means of the ddcswr setting.
901 icmr1? 2 c bus mode register 1 h'ff8f iic1 icmr0? 2 c bus mode register 0 h'ffdf iic0 7 mls 0 r/w 6 wait 0 r/w 5 cks2 0 r/w 4 cks1 0 r/w 3 cks0 0 r/w 0 bc0 0 r/w 2 bc2 0 r/w 1 bc1 0 r/w bit initial value read/write bit counter bc2 bc1 0 1 0 1 0 1 bc0 0 1 0 1 0 1 0 1 note: * do not set this bit to 1 when the i 2 c bus format is used. note: maximum operating frequency of h8s/2169 and h8s/2149 is 10 mhz. synchronous serial format 8 1 2 3 4 5 6 7 i 2 c bus format 9 2 3 4 5 6 7 8 serial clock select cks2 cks1 0 1 0 1 0 1 0 1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 iicx 0 1 clock ?28 ?40 ?48 ?64 ?80 ?100 ?112 ?128 ?56 ?80 ?96 ?128 ?160 ?200 ?224 ?256 wait insertion bit 0 data and acknowledge bits transferred consecutively 1 wait inserted between data and acknowledge bits msb-first/lsb-first select * 0 msb-first 1 lsb-first ?= 5 mhz 179 khz 125 khz 104 khz 78.1 khz 62.5 khz 50.0 khz 44.6 khz 39.1 khz 89.3 khz 62.5 khz 52.1 khz 39.1 khz 31.3 khz 25.0 khz 22.3 khz 19.5 khz ?= 8 mhz transfer rate 286 khz 200 khz 167 khz 125 khz 100 khz 80.0 khz 71.4 khz 62.5 khz 143 khz 100 khz 83.3 khz 62.5 khz 50.0 khz 40.0 khz 35.7 khz 31.3 khz ?= 10 mhz 357 khz 250 khz 208 khz 156 khz 125 khz 100 khz 89.3 khz 78.1 khz 179 khz 125 khz 104 khz 78.1 khz 62.5 khz 50.0 khz 44.6 khz 39.1 khz
902 tier?imer interrupt enable register h'ff90 frt 7 iciae 0 r/w 6 icibe 0 r/w 5 icice 0 r/w 4 icide 0 r/w 3 ociae 0 r/w 0 1 2 ocibe 0 r/w 1 ovie 0 r/w bit initial value read/write input capture interrupt a enable 0 input capture interrupt request a (icia) is disabled 1 input capture interrupt request a (icia) is enabled input capture interrupt b enable 0 input capture interrupt request b (icib) is disabled 1 input capture interrupt request b (icib) is enabled input capture interrupt c enable 0 input capture interrupt request c (icic) is disabled 1 input capture interrupt request c (icic) is enabled input capture interrupt d enable 0 input capture interrupt request d (icid) is disabled 1 input capture interrupt request d (icid) is enabled output compare interrupt a enable 0 output compare interrupt request a (ocia) is disabled 1 output compare interrupt request a (ocia) is enabled output compare interrupt b enable 0 output compare interrupt request b (ocib) is disabled 1 output compare interrupt request b (ocib) is enabled timer overflow interrupt enable 0 timer overflow interrupt request (fovi) is disabled 1 timer overflow interrupt request (fovi) is enabled
903 tcsr?imer control/status register h'ff91 frt 7 icfa 0 r/(w) * 6 icfb 0 r/(w) * 5 icfc 0 r/(w) * 4 icfd 0 r/(w) * 3 ocfa 0 r/(w) * 0 cclra 0 r/w 2 ocfb 0 r/(w) * 1 ovf 0 r/(w) * bit initial value read/write input capture flag a note: * only 0 can be written in bits 7 to 1, to clear the flags. 0 [clearing condition] read icfa when icfa = 1, then write 0 in icfa 1 [setting condition] when an input capture signal causes the frc value to be transferred to icra input capture flag b 0 [clearing condition] read icfb when icfb = 1, then write 0 in icfb 1 [setting condition] when an input capture signal causes the frc value to be transferred to icrb input capture flag c 0 [clearing condition] read icfc when icfc = 1, then write 0 in icfc 1 [setting condition] when an input capture signal is received input capture flag d 0 [clearing condition] read icfd when icfd = 1, then write 0 in icfd 1 [setting condition] when an input capture signal is received counter clear a 0 frc clearing is disabled 1 frc is cleared at compare match a timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when frc changes from h'ffff to h'0000 output compare flag b 0 [clearing condition] read ocfb when ocfb = 1, then write 0 in ocfb 1 [setting condition] when frc = ocrb output compare flag a 0 [clearing condition] read ocfa when ocfa = 1, then write 0 in ocfa 1 [setting condition] when frc = ocra
904 frc?ree-running counter h'ff92 frt 15 0 r/w 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 8 0 r/w 10 0 r/w 9 0 r/w bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w count value ocra/ocrb?utput compare register a/b h'ff94 frt 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 8 1 r/w 10 1 r/w 9 1 r/w bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w constantly compared with frc value; ocf is set when ocr = frc
905 tcr?imer control register h'ff96 frt 7 iedga 0 r/w 6 iedgb 0 r/w 5 iedgc 0 r/w 4 iedgd 0 r/w 3 bufea 0 r/w 0 cks0 0 r/w 2 bufeb 0 r/w 1 cks1 0 r/w bit initial value read/write input edge select a 0 capture on the falling edge of ftia capture on the rising edge of ftia 1 input edge select b 0 capture on the falling edge of ftib capture on the rising edge of ftib 1 input edge select c 0 capture on the falling edge of ftic capture on the rising edge of ftic 1 input edge select d 0 capture on the falling edge of ftid capture on the rising edge of ftid 1 buffer enable a 0 icrc is not used as a buffer register for input capture a icrc is used as a buffer register for input capture a 1 buffer enable b 0 icrd is not used as a buffer register for input capture b 1 clock select 0 ?2 internal clock source 0 1 ?8 internal clock source ?32 internal clock source external clock source (rising edge) 0 1 1 icrd is used as a buffer register for input capture b
906 tocr?imer output compare control register h'ff97 frt 7 icrdms 0 r/w 6 ocrams 0 r/w 5 icrs 0 r/w 4 ocrs 0 r/w 3 oea 0 r/w 0 olvlb 0 r/w 2 oeb 0 r/w 1 olvla 0 r/w bit initial value read/write output level b 0 0 output at compare- match b 1 1 output at compare- match b output level a 0 0 output at compare- match a 1 1 output at compare- match a output enable b 0 output compare b output disabled 1 output compare b output enabled output enable a 0 output compare a output disabled 1 output compare a output enabled output compare register select 0 ocra register selected 1 ocrb register selected input capture register select 0 icra, icrb, and icrc registers selected 1 ocrar, ocraf, and ocrdm registers selected output compare a mode select 0 ocra set to normal operating mode 1 ocra set to operating mode using ocrar and ocraf input capture d mode select 0 icrd set to normal operating mode 1 icrd set to operating mode using ocrdm
907 ocrar?utput compare register ar h'ff98 frt ocraf?utput compare register af h'ff9a frt 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 8 1 r/w 10 1 r/w 9 1 r/w bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w used for ocra operation when ocrams = 1 in tocr (for details, see section 11.2.4, output compare registers ar and af (ocrar, ocraf).) ocrdm?utput compare register dm h'ff9c frt 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 8 0 r 10 0 r 9 0 r bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w used for icrd operation when icrdms = 1 in tocr (for details, see section 11.2.5, output compare register dm (ocrdm).) icra?nput capture register a h'ff98 frt icrb?nput capture register b h'ff9a frt icrc?nput capture register c h'ff9c frt icrd?nput capture register d h'ff9e frt 15 0 r 14 0 r 13 0 r 12 0 r 11 0 r 8 0 r 10 0 r 9 0 r bit initial value read/write 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r stores frc value when input capture signal is input (icrc and icrd can be used for buffer operation. for details, see section 11.2.3, input capture registers a to d (icra to icrd).)
908 dadrah?wm (d/a) data register ah h'ffa0 pwmx dadral?wm (d/a) data register al h'ffa1 pwmx dadrbh?wm (d/a) data register bh h'ffa6 pwmx dadrbl?wm (d/a) data register bl h'ffa7 pwmx 15 13 da13 1 r/w 14 12 da12 1 r/w 13 11 da11 1 r/w 12 10 da10 1 r/w 11 9 da9 1 r/w 8 6 da6 1 r/w 10 8 da8 1 r/w 9 7 da7 1 r/w bit (cpu) bit (data) dadra initial value read/write 7 5 da5 1 r/w 6 4 da4 1 r/w 5 3 da3 1 r/w 4 2 da2 1 r/w 3 1 da1 1 r/w 0 1 2 0 da0 1 r/w 1 cfs 1 r/w dadrh dadrl da13 1 r/w da12 1 r/w da11 1 r/w da10 1 r/w da9 1 r/w da6 1 r/w da8 1 r/w da7 1 r/w dadrb initial value read/write da5 1 r/w da4 1 r/w da3 1 r/w da2 1 r/w da1 1 r/w regs 1 r/w da0 1 r/w cfs 1 r/w register select (dadrb only) 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed carrier frequency select 0 base cycle = resolution (t) 64 dadr range is h'0401 to h'fffd 1 base cycle = resolution (t) 256 dadr range is h'0103 to h'ffff d/a conversion data
909 dacr?wm (d/a) control register h'ffa0 pwmx 7 test 0 r/w 6 pwme 0 r/w 5 1 4 1 3 oeb 0 r/w 0 cks 0 r/w 2 oea 0 r/w 1 os 0 r/w bit initial value read/write clock select 0 operates at resolution (t) = system clock cycle time (t cyc ) 1 operates at resolution (t) = system clock cycle time (t cyc ) 2 output select 0 direct pwm output 1 inverted pwm output output enable a 0 pwm (d/a) channel a output (pwx0 output pin) disabled 1 pwm (d/a) channel a output (pwx0 output pin) enabled output enable b 0 pwm (d/a) channel b output (pwx1 output pin) disabled 1 pwm (d/a) channel b output (pwx1 output pin) enabled pwm enable 0 dacnt operates as a 14-bit up-counter 1 dacnt halts at h'0003 test mode 0 pwm (d/a) in user state: normal operation 1 pwm (d/a) in test state: correct conversion results unobtainable
910 dacnth?wm (d/a) counter h h'ffa6 pwmx dacntl?wm (d/a) counter l h'ffa7 pwmx 15 7 0 r/w 14 6 0 r/w 13 5 0 r/w 12 4 0 r/w 11 3 0 r/w 8 0 0 r/w 10 2 0 r/w 9 1 0 r/w bit (cpu) bit (counter) initial value read/write 7 8 0 r/w 6 9 0 r/w 5 10 0 r/w 4 11 0 r/w 3 12 0 r/w 0 regs 1 r/w 2 13 0 r/w 1 1 dacnth dacntl up-counter register select 0 dadra and dadrb can be accessed 1 dacr and dacnt can be accessed
911 tcsr0?imer control/status register 0 h'ffa8 wdt0 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 rsts 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcsr0 clock select 2 to 0 cks2 0 1 ?/2 ?/64 ?/128 ?/512 ?/2048 ?/8192 ?/32768 ?/131072 cks1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 note: * only 0 can be written, to clear the flag. clock reset or nmi 0 nmi interrupt requested 1 internal reset requested timer enable 0 tcnt is initialized to h'00 and halted 1 tcnt counts reserved bit timer mode select 0 interval timer mode: sends the cpu an interval timer interrupt request (wovi) when tcnt overflows 1 watchdog timer mode: generates a reset or nmi interrupt when tcnt overflows reso pin output goes low simultaneously (when internal reset is selected) overflow flag 0 [clearing conditions] write 0 in the tme bit read tcsr when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows (changes from h'ff to h'00) (when internal reset request generation is selected in watchdog timer mode, ovf is cleared automatically by the internal reset.)
912 tcnt0?imer counter 0 h'ffa8 (w), h'ffa9 (r) wdt0 tcnt1?imer counter 1 h'ffea (w), h'ffeb (r) wdt1 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write up-counter paodr?ort a output data register h'ffaa port a 7 pa7odr 0 r/w 6 pa6odr 0 r/w 5 pa5odr 0 r/w 4 pa4odr 0 r/w 3 pa3odr 0 r/w 0 pa0odr 0 r/w 2 pa2odr 0 r/w 1 pa1odr 0 r/w bit initial value read/write output data for port a pins papin?ort a input data register h'ffab (r) port a 7 pa7pin * r 6 pa6pin * r 5 pa5pin * r 4 pa4pin * r 3 pa3pin * r 0 pa0pin * r 2 pa2pin * r 1 pa1pin * r bit initial value read/write note: * determined b y state of pins pa7 to pa0. port a pin states paddr?ort a data direction register h'ffab (w) port a 7 pa7ddr 0 w 6 pa6ddr 0 w 5 pa5ddr 0 w 4 pa4ddr 0 w 3 pa3ddr 0 w 0 pa0ddr 0 w 2 pa2ddr 0 w 1 pa1ddr 0 w bit initial value read/write specification of input or output for port a pins
913 p1pcr?ort 1 mos pull-up control register h'ffac port 1 7 p17pcr 0 r/w 6 p16pcr 0 r/w 5 p15pcr 0 r/w 4 p14pcr 0 r/w 3 p13pcr 0 r/w 0 p10pcr 0 r/w 2 p12pcr 0 r/w 1 p11pcr 0 r/w bit initial value read/write control of port 1 built-in mos input pull-ups p2pcr?ort 2 mos pull-up control register h'ffad port 2 7 p27pcr 0 r/w 6 p26pcr 0 r/w 5 p25pcr 0 r/w 4 p24pcr 0 r/w 3 p23pcr 0 r/w 0 p20pcr 0 r/w 2 p22pcr 0 r/w 1 p21pcr 0 r/w bit initial value read/write control of port 2 built-in mos input pull-ups p3pcr?ort 3 mos pull-up control register h'ffae port 3 7 p37pcr 0 r/w 6 p36pcr 0 r/w 5 p35pcr 0 r/w 4 p34pcr 0 r/w 3 p33pcr 0 r/w 0 p30pcr 0 r/w 2 p32pcr 0 r/w 1 p31pcr 0 r/w bit initial value read/write control of port 3 built-in mos input pull-ups p1ddr?ort 1 data direction register h'ffb0 port 1 7 p17ddr 0 w 6 p16ddr 0 w 5 p15ddr 0 w 4 p14ddr 0 w 3 p13ddr 0 w 0 p10ddr 0 w 2 p12ddr 0 w 1 p11ddr 0 w bit initial value read/write specification of input or output for port 1 pins
914 p2ddr?ort 2 data direction register h'ffb1 port 2 7 p27ddr 0 w 6 p26ddr 0 w 5 p25ddr 0 w 4 p24ddr 0 w 3 p23ddr 0 w 0 p20ddr 0 w 2 p22ddr 0 w 1 p21ddr 0 w bit initial value read/write specification of input or output for port 2 pins p1dr?ort 1 data register h'ffb2 port 1 7 p17dr 0 r/w 6 p16dr 0 r/w 5 p15dr 0 r/w 4 p14dr 0 r/w 3 p13dr 0 r/w 0 p10dr 0 r/w 2 p12dr 0 r/w 1 p11dr 0 r/w bit initial value read/write output data for port 1 pins p2dr?ort 2 data register h'ffb3 port 2 7 p27dr 0 r/w 6 p26dr 0 r/w 5 p25dr 0 r/w 4 p24dr 0 r/w 3 p23dr 0 r/w 0 p20dr 0 r/w 2 p22dr 0 r/w 1 p21dr 0 r/w bit initial value read/write output data for port 2 pins p3ddr?ort 3 data direction register h'ffb4 port 3 7 p37ddr 0 w 6 p36ddr 0 w 5 p35ddr 0 w 4 p34ddr 0 w 3 p33ddr 0 w 0 p30ddr 0 w 2 p32ddr 0 w 1 p31ddr 0 w bit initial value read/write specification of input or output for port 3 pins
915 p4ddr?ort 4 data direction register h'ffb5 port 4 7 p47ddr 0 w 6 p46ddr 0 w 5 p45ddr 0 w 4 p44ddr 0 w 3 p43ddr 0 w 0 p40ddr 0 w 2 p42ddr 0 w 1 p41ddr 0 w bit initial value read/write specification of input or output for port 4 pins p3dr?ort 3 data register h'ffb6 port 3 7 p37dr 0 r/w 6 p36dr 0 r/w 5 p35dr 0 r/w 4 p34dr 0 r/w 3 p33dr 0 r/w 0 p30dr 0 r/w 2 p32dr 0 r/w 1 p31dr 0 r/w bit initial value read/write output data for port 3 pins p4dr?ort 4 data register h'ffb7 port 4 7 p47dr 0 r/w 6 p46dr 0 r/w 5 p45dr 0 r/w 4 p44dr 0 r/w 3 p43dr 0 r/w 0 p40dr 0 r/w 2 p42dr 0 r/w 1 p41dr 0 r/w bit initial value read/write output data for port 4 pins p5ddr?ort 5 data direction register h'ffb8 port 5 7 1 6 1 5 1 4 1 3 1 0 p50ddr 0 w 2 p52ddr 0 w 1 p51ddr 0 w bit initial value read/write specification of input or output for port 5 pins
916 p6ddr?ort 6 data direction register h'ffb9 port 6 7 p67ddr 0 w 6 p66ddr 0 w 5 p65ddr 0 w 4 p64ddr 0 w 3 p63ddr 0 w 0 p60ddr 0 w 2 p62ddr 0 w 1 p61ddr 0 w bit initial value read/write specification of input or output for port 6 pins p5dr?ort 5 data register h'ffba port 5 7 1 6 1 5 1 4 1 3 1 0 p50dr 0 r/w 2 p52dr 0 r/w 1 p51dr 0 r/w bit initial value read/write output data for port 5 pins p6dr?ort 6 data register h'ffbb port 6 7 p67dr 0 r/w 6 p66dr 0 r/w 5 p65dr 0 r/w 4 p64dr 0 r/w 3 p63dr 0 r/w 0 p60dr 0 r/w 2 p62dr 0 r/w 1 p61dr 0 r/w bit initial value read/write output data for port 6 pins pbodr?ort b output data register h'ffbc port b 7 pb7odr 0 r/w 6 pb6odr 0 r/w 5 pb5odr 0 r/w 4 pb4odr 0 r/w 3 pb3odr 0 r/w 0 pb0odr 0 r/w 2 pb2odr 0 r/w 1 pb1odr 0 r/w bit initial value read/write output data for port b pins
917 p8ddr?ort 8 data direction register h'ffbd (w) port 8 7 1 6 p86ddr 0 w 5 p85ddr 0 w 4 p84ddr 0 w 3 p83ddr 0 w 0 p80ddr 0 w 2 p82ddr 0 w 1 p81ddr 0 w bit initial value read/write specification of input or output for port 8 pins pbpin?ort b input data register h'ffbd (r) port b 7 pb7pin * r 6 pb6pin * r 5 pb5pin * r 4 pb4pin * r 3 pb3pin * r 0 pb0pin * r 2 pb2pin * r 1 pb1pin * r bit initial value read/write note: * determined by state of pins pb7 to pb0. port b pin states pbddr?ort b data direction register h'ffbe (w) port b 7 pb7ddr 0 w 6 pb6ddr 0 w 5 pb5ddr 0 w 4 pb4ddr 0 w 3 pb3ddr 0 w 0 pb0ddr 0 w 2 pb2ddr 0 w 1 pb1ddr 0 w bit initial value read/write specification of input or output for port b pins p7pin?ort 7 input data register h'ffbe (r) port 7 7 p77pin * r 6 p76pin * r 5 p75pin * r 4 p74pin * r 3 p73pin * r 0 p70pin * r 2 p72pin * r 1 p71pin * r bit initial value read/write note: * determined b y state of pins p77 to p70. port 7 pin states
918 p8dr?ort 8 data register h'ffbf port 8 7 1 6 p86dr 0 r/w 5 p85dr 0 r/w 4 p84dr 0 r/w 3 p83dr 0 r/w 0 p80dr 0 r/w 2 p82dr 0 r/w 1 p81dr 0 r/w bit initial value read/write output data for port 8 pins p9ddr?ort 9 data direction register h'ffc0 port 9 7 p97ddr 0 w 0 w 6 p96ddr 1 w 0 w 5 p95ddr 0 w 0 w 4 p94ddr 0 w 0 w 3 p93ddr 0 w 0 w 0 p90ddr 0 w 0 w 2 p92ddr 0 w 0 w 1 p91ddr 0 w 0 w bit mode 1 initial value read/write modes 2 and 3 initial value read/write specification of input or output for port 9 pins p9dr?ort 9 data register h'ffc1 port 9 7 p97dr 0 r/w 6 p96dr * r 5 p95dr 0 r/w 4 p94dr 0 r/w 3 p93dr 0 r/w 0 p90dr 0 r/w 2 p92dr 0 r/w 1 p91dr 0 r/w bit initial value read/write note: * determined by state of pin p96. output data for port 9 pins
919 ier?rq enable register h'ffc2 interrupt controller 7 irq7e 0 r/w 6 irq6e 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 irq3e 0 r/w 0 irq0e 0 r/w 2 irq2e 0 r/w 1 irq1e 0 r/w bit initial value read/write irq7 to irq0 enable 0 irqn interrupt disabled 1 irqn interrupt enabled (n = 7 to 0)
920 stcr?erial timer control register h'ffc3 system 7 iics 0 r/w 6 iicx1 0 r/w 5 iicx0 0 r/w 4 iice 0 r/w 3 flshe 0 r/w 0 icks0 0 r/w 2 0 r/w 1 icks1 0 r/w bit initial value read/write notes: 1. 2. internal clock source select * 1 reserved bit flash memory control register enable 0 flash memory control register not selected 1 flash memory control register selected i 2 c master enable 0 cpu access to sci0, sci1, and sci2 control registers is enabled 1 cpu access to i 2 c bus interface data, pwmx and control registers is enabled 0 pa7 to pa4 are normal i/o pins 1 pa7 to pa4 are i/o pins with bus driving capability i 2 c transfer select 1 and 0 * 2 i 2 c extra buffer select used for 8-bit timer input clock selection. for details, see section 12.2.4, timer control register (tcr). used for i 2 c bus interface transfer clock selection. for details, see section 16.2.4, i 2 c bus mode register (icmr).
921 syscr?ystem control register h'ffc4 system 7 cs2e 0 r/w 6 iose 0 r/w 5 intm1 0 r 4 intm0 0 r/w 3 xrst 1 r 0 rame 1 r/w 2 nmieg 0 r/w 1 hie 0 r/w bit initial value read/write ram enable 0 on-chip ram is disabled 1 on-chip ram is enabled host interface enable 0 addresses h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff are used for access to 8-bit timer (channel x and y) data registers and control registers, and timer connection control registers 1 addresses h'(ff)fff0 to h'(ff)fff7 and h'(ff)fffc to h'(ff)ffff are used for access to host interface data registers and control registers, and keyboard controller and mos input pull-up control registers nmi edge select 0 falling edge 1 rising edge external reset 0 reset generated by watchdog timer overflow 1 reset generated by an external reset interrupt control selection mode 1 and 0 intm1 bit 5 interrupts controlled by i bit (initial value) interrupts controlled by i and ui bits, and icr cannot be used in the lsi cannot be used in the lsi intm0 bit 4 interrupt control mode description 0 1 00 1 2 3 1 0 1 cs2 enable 0 cs2 pin function halted ( cs2 fixed high internally) 0 cs2e fga20e 1 1 cs2 pin function selected for p81/ cs2 pin 0 cs2 pin function selected for p90/ ecs2 pin 1 description syscr bit 7 hicr bit 0 ios enable 0 the as / ios pin functions as the address strobe pin (low output when accessing an external area) 1 the as / ios pin functions as the i/o strobe pin (low output when accessing a specified address from h'(ff)f000 to h'(ff)f7ff)
922 mdcr?ode control register h'ffc5 system 7 expe * r/w * 6 0 5 0 4 0 3 0 0 mds0 * r 2 0 1 mds1 * r bit initial value read/write expanded mode enable 0 single-chip mode selected 1 expanded mode selected note: * determined by the md1 and md0 pins. mode pin state
923 bcr?us control register h'ffc6 bus controller 7 icis1 1 r/w 6 icis0 1 r/w 5 brstrm 0 r/w 4 brsts1 1 r/w 3 brsts0 0 r/w 0 ios0 1 r/w 2 1 r/w 1 ios1 1 r/w bit initial value read/write ios select ios1 address for which as / ios pin output goes low when iose = 1 0 low in access to address h'(ff)f000 to h'(ff)f03f ios0 0 low in access to address h'(ff)f000 to h'(ff)f0ff 1 1 low in access to address h'(ff)f000 to h'(ff)f3ff 0 low in access to address h'(ff)f000 to h'(ff)f7ff 1 burst cycle select 0 0 max. 4 words in burst access 1 max. 8 words in burst access burst cycle select 1 0 burst cycle comprises 1 state 1 burst cycle comprises 2 states burst rom enable 0 basic bus interface 1 burst rom interface idle cycle insert 0 0 idle cycle not inserted in case of successive external read and external write cycles 1 idle cycle inserted in case of successive external read and external write cycles reserved bit
924 wscr?ait state control register h'ffc7 bus controller 7 rams 0 r/w 6 ram0 0 r/w 5 abw 1 r/w 4 ast 1 r/w 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w bit initial value read/write reserved bits wait count 1 and 0 0 no program wait states are inserted 0 1 program wait state is inserted in external memory space accesses 1 1 2 program wait states are inserted in external memory space accesses 0 3 program wait states are inserted in external memory space accesses 1 wait mode select 1 and 0 0 program wait mode 0 wait disabled mode 1 1 pin wait mode 0 pin auto-wait mode 1 access state control 0 external memory space is designated as 2-state access space wait state insertion in external memory space accesses is disabled 1 external memory space is designated as 3-state access space wait state insertion in external memory space accesses is enabled bus width control 0 external memory space designated as 16-bit access space 1 external memory space designated as 8-bit access space
925 tcr0?imer control register 0 h'ffc8 tmr0 tcr1?imer control register 1 h'ffc9 tmr1 tcrx?imer control register x h'fff0 tmrx tcry?imer control register y h'fff0 tmry 7 cmieb 0 r/w 6 cmiea 0 r/w 5 ovie 0 r/w 4 cclr1 0 r/w 3 cclr0 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write clock select 2 to 0 channel bit 2 bit 1 bit 0 cks2 0 1 x y all 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 cks1 cks0 description clock input disabled internal clock: counting at falling edge of ?8 internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?64 internal clock: counting at falling edge of ?32 internal clock: counting at falling edge of ?1024 internal clock: counting at falling edge of ?256 counting at tcnt1 overflow signal * 2 clock input disabled internal clock: counting at falling edge of ?8 internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?64 internal clock: counting at falling edge of ?128 internal clock: counting at falling edge of ?1024 internal clock: counting at falling edge of ?2048 count at tcnt0 compare match a * 2 clock input disabled internal clock: counting on internal clock: counting at falling edge of ?2 internal clock: counting at falling edge of ?4 clock input disabled clock input disabled internal clock: counting at falling edge of ?4 internal clock: counting at falling edge of ?256 internal clock: counting at falling edge of ?2048 clock input disabled external clock: counting at rising edge external clock: counting at falling edge external clock: counting at both rising and falling edges * 1 * 1 * 1 * 1 * 1 * 1 notes: 1. 2. selected by icks1 and icks0 in stcr. for details, see section 12.2.4, timer control register (tcr). if the clock input of channel 0 is the tcnt1 overflow signal and that of channel 1 is the tcnt0 compare match signal, no incrementing clock is generated. do not use this setting. counter clear 1 and 0 0 clear is disabled cleared on compare match a 0 1 1 cleared on compare match b 0 cleared on rising edge of external reset input 1 timer overflow interrupt enable 0 ovf interrupt request (ovi) is disabled 1 ovf interrupt request (ovi) is enabled compare match interrupt enable a 0 cmfa interrupt request (cmia) is disabled 1 cmfa interrupt request (cmia) is enabled compare match interrupt enable b 0 cmfb interrupt request (cmib) is disabled 1 cmfb interrupt request (cmib) is enabled
926 tcsr0?imer control/status register 0 h'ffca tmr0 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 adte 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr0 output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 a/d trigger enable 0 a/d converter start requests by compare match a are disabled 1 a/d converter start requests by compare match a are enabled timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? read cmfa when cmfa = 1, then write 0 in cmfa ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? read cmfb when cmfb = 1, then write 0 in cmfb ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 5, to clear the flags.
927 tcsr1?imer control/status register 1 h'ffcb tmr1 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 1 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsr1 output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 timer overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? read cmfa when cmfa = 1, then write 0 in cmfa ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? read cmfb when cmfb = 1, then write 0 in cmfb ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb note: * only 0 can be written in bits 7 to 5, to clear the flags.
928 tcora0?ime constant register a0 h'ffcc tmr0 tcora1?ime constant register a1 h'ffcd tmr1 tcorb0?ime constant register b0 h'ffce tmr0 tcorb1?ime constant register b1 h'ffcf tmr1 tcoray?ime constant register ay h'fff2 tmry tcorby?ime constant register by h'fff3 tmry tcorc?ime constant register c h'fff5 tmrx tcorax?ime constant register ax h'fff6 tmrx tcorbx?ime constant register bx h'fff7 tmrx 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write 15 1 r/w bit initial value read/write 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w tcora0 tcorb0 tcora1 tcorb1 compare match flag (cmf) is set when tcor and tcnt values match compare match flag (cmf) is set when tcor and tcnt values match 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w bit initial value read/write compare match c signal is generated when sum of tcorc and ticr contents match tcnt value tcorax, tcoray tcorbx, tcorby tcorc
929 tcnt0?imer counter 0 h'ffd0 tmr0 tcnt1?imer counter 1 h'ffd1 tmr1 tcntx?imer counter x h'fff4 tmrx tcnty?imer counter y h'fff4 tmry 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write up-counter 15 0 r/w bit initial value read/write 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w tcnt0 tcnt1 up-counter tcntx, tcnty
930 pwoera?wm output enable register a h'ffd3 pwm pwoerb?wm output enable register b h'ffd2 pwm 7 oe7 0 r/w 6 oe6 0 r/w 5 oe5 0 r/w 4 oe4 0 r/w 3 oe3 0 r/w 0 oe0 0 r/w 2 oe2 0 r/w 1 oe1 0 r/w bit pwoera initial value read/write 7 oe15 0 r/w 6 oe14 0 r/w 5 oe13 0 r/w 4 oe12 0 r/w 3 oe11 0 r/w switching between pwm output and port output 0 oe8 0 r/w 2 oe10 0 r/w 1 oe9 0 r/w bit pwoerb initial value read/write 0 1 0 1 0 1 port input port input port output or pwm 256/256 output pwm output (0 to 255/256 output) ddr oe description pwdpra?wm data polarity register a h'ffd5 pwm pwdprb?wm data polarity register b h'ffd4 pwm 7 os7 0 r/w 6 os6 0 r/w 5 os5 0 r/w 4 os4 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit pwdpra initial value read/write 7 os15 0 r/w 6 os14 0 r/w 5 os13 0 r/w 4 os12 0 r/w 3 os11 0 r/w 0 os8 0 r/w 2 os10 0 r/w 1 os9 0 r/w bit pwdprb initial value read/write pwm output polarity control 0 pwm direct output (pwdr value corresponds to high width of output) 1 pwm inverted output (pwdr value corresponds to low width of output)
931 pwsl?wm register select h'ffd6 pwm 7 pwcke 0 r/w 6 pwcks 0 r/w 5 1 4 0 3 rs3 0 r/w 0 rs0 0 r/w 2 rs2 0 r/w 1 rs1 0 r/w bit initial value read/write 0 1 pwdr0 selected pwdr1 selected pwdr2 selected pwdr3 selected pwdr4 selected pwdr5 selected pwdr6 selected pwdr7 selected pwdr8 selected pwdr9 selected pwdr10 selected pwdr11 selected pwdr12 selected pwdr13 selected pwdr14 selected pwdr15 selected register select 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 pwm clock enable, pwm clock select clock input disabled ?(system clock) selected ?2 selected ?4 selected ?8 selected ?16 selected pwsl pcsr bit 2 pwckb 0 1 bit 1 pwcka 0 1 0 1 bit 7 pwcke 0 1 bit 6 pwcks 0 1 description
932 pwdr0 to pwdr15?wm data registers h'ffd7 pwm 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w specifies duty factor of basic output pulse and number of additional pulses 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write addrah?/d data register ah h'ffe0 a/d converter addral?/d data register al h'ffe1 a/d converter addrbh?/d data register bh h'ffe2 a/d converter addrbl?/d data register bl h'ffe3 a/d converter addrch?/d data register ch h'ffe4 a/d converter addrcl?/d data register cl h'ffe5 a/d converter addrdh?/d data register dh h'ffe6 a/d converter addrdl?/d data register dl h'ffe7 a/d converter 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 0 r 4 0 r 2 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 0 r 5 0 r 3 0 r bit initial value read/write addrh stores a/d data correspondence between analog input channels and addr registers addrl addra addrb addrc addrd group 0 an0 an1 an2 an3 group 1 an4 an5 an6 or cin0 to cin7 an7 or cin8 to cin15 analog input channel a/d data register
933 adcsr?/d control/status register h'ffe8 a/d converter 7 adf 0 r/(w) 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w * bit initial value read/write channel select 0 1 0 1 0 1 0 1 0 1 0 1 an0 an1 an2 an3 an4 an5 an6 or cin0 to 7 an7 or cin8 to 15 description an0 an0, an1 an0, an1, an2 an0, an1, an2, an3 an4 an4, an5 an4, an5, an6 or cin0 to 7 an4, an5, an6 or cin0 to 7, an7 or cin8 to 15 group selection ch1 ch0 single mode scan mode ch2 0 1 note: * only 0 can be written, to clear the flag. channel selection clock select 0 conversion time = 266 states (max.) 1 conversion time = 134 states (max.) scan mode 0 single mode 1 scan mode a/d interrupt enable 0 a/d conversion end interrupt (adi) request disabled 1 a/d conversion end interrupt (adi) request enabled a/d end flag 0 [clearing conditions] ? when 0 is written in the adf flag after reading adf = 1 ? when the dtc is activated by an adi interrupt, and addr is read 1 [setting conditions] ? single mode: when a/d conversion ends ? scan mode: when a/d conversion ends on all specified channels a/d start 0 a/d conversion stopped 1 single mode: a/d conversion is started. cleared to 0 automatically when conversion on the specified channel ends ? scan mode: a/d conversion is started. conversion continues sequentially on the selected channels until adst is cleared to 0 by software, a reset, or a transition to standby mode or module stop mode
934 adcr?/d control register h'ffe9 a/d converter 7 trgs1 0 r/w 6 trgs0 0 r/w 5 1 4 1 3 1 0 1 2 1 1 1 bit initial value read/write timer trigger select 0 start of a/d conversion by external trigger is disabled start of a/d conversion by external trigger is disabled start of a/d conversion by external trigger (8-bit timer) is enabled start of a/d conversion by external trigger pin is enabled 0 1 10 1
935 tcsr1?imer control/status register 1 h'ffea wdt1 7 ovf 0 r/(w) * 1 6 wt/ it 0 r/w 5 tme 0 r/w 4 pss 0 r/w 3 rst/ nmi 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w bit initial value read/write tcsr1 clock select 2 to 0 pss 0 1 clock cks2 0 1 0 1 cks1 0 1 0 1 0 1 0 1 cks0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 notes: 1. 2. ?/2 ?/64 ?/128 ?/512 ?/2048 ?/8192 ?/32768 ?/131072 ?sub/2 ?sub/4 ?sub/8 ?sub/16 ?sub/32 ?sub/64 ?sub/128 ?sub/256 reset or nmi 0 nmi interrupt requested 1 internal reset requested prescaler select * 2 0 tcnt counts on a ?-based prescaler (psm) divided clock pulses 1 tcnt counts on a ?sub-based prescaler (pss) divided clock pulses timer enable 0 tcnt is initialized to h'00 and halted 1 tcnt counts timer mode select 0 interval timer mode: interval timer interrupt request (wovi) sent to cpu when tcnt overflows 1 watchdog timer mode: reset or nmi interrupt request sent to cpu when tcnt overflows reso pin output goes low simultaneously (when internal reset is selected) overflow flag 0 [clearing conditions] when 0 is written in the tme bit when 0 is written in ovf after reading tcsr when ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 when internal reset request is selected in watchdog timer mode, ovf is cleared automatically by an internal reset after being set only 0 can be written, to clear the flag. for operation control when a transition is made to power-down mode, see section 24.2.3, timer control/status register (tcsr).
936 hicr?ost interface control register h'fff0 hif (xbs) 7 1 6 1 5 1 4 1 3 1 0 fga20e 0 r/w 2 ibfie2 0 r/w 1 ibfie1 0 r/w bit initial value slave r/w host r/w fast a20 gate function enable 0 1 hif: xbs fast a20 gate function disabled hif: xbs fast a20 gate function disabled setting prohibited hif: xbs fast a20 gate function enabled input data register full interrupt enable 1 0 input data register (idr1) receive complete interrupt request is disabled 1 input data register (idr1) receive complete interrupt request is enabled input data register full interrupt enable 2 0 input data register (idr2) receive complete interrupt request is disabled 1 input data register (idr2) receive complete interrupt request is enabled fga20e 0 1 0 1 p81ddr description
937 tcsrx?imer control/status register x h'fff1 tmrx 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icf 0 r/(w) * 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsrx output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 input capture flag 0 [clearing condition] when 0 is written in icf after reading icf = 1 1 [setting condition] when a rising edge followed by a falling edge is detected in the external reset signal after the icst bit in tconri has been set to 1 timer overflow flag 0 [clearing condition] when 0 is written in ovf after reading ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? when 0 is written in cmfa after reading cmfa = 1 ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? when 0 is written in cmfb after reading cmfb = 1 ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 4, to clear the flags.
938 tcsry?imer control/status register y h'fff1 tmry 7 cmfb 0 r/(w) * 6 cmfa 0 r/(w) * 5 ovf 0 r/(w) * 4 icie 0 r/w 3 os3 0 r/w 0 os0 0 r/w 2 os2 0 r/w 1 os1 0 r/w bit initial value read/write tcsry output select 1 and 0 0 no change at compare match a 0 0 output at compare match a 1 1 1 output at compare match a 0 output inverted at compare match a (toggle output) 1 note: output select 3 and 2 0 no change at compare match b 0 0 output at compare match b 1 1 1 output at compare match b 0 output inverted at compare match b (toggle output) 1 input capture interrupt enable 0 interrupt request by icf (icix) is disabled 1 interrupt request by icf (icix) is enabled timer overflow flag 0 [clearing condition] when 0 is written in ovf after reading ovf = 1 1 [setting condition] when tcnt overflows from h'ff to h'00 compare match flag a 0 [clearing conditions] ? when 0 is written in cmfa after reading cmfa = 1 ? when the dtc is activated by a cmia interrupt 1 [setting condition] when tcnt = tcora compare match flag b 0 [clearing conditions] ? when 0 is written in cmfb after reading cmfb = 1 ? when the dtc is activated by a cmib interrupt 1 [setting condition] when tcnt = tcorb * only 0 can be written in bits 7 to 5, to clear the flags.
939 kmimr?eyboard matrix interrupt mask register h'fff1 interrupt controller kmimra?eyboard matrix interrupt mask register a h'fff3 interrupt controller 7 kmimr7 1 r/w 6 kmimr6 0 r/w 5 kmimr5 1 r/w 4 kmimr4 1 r/w 3 kmimr3 1 r/w 0 kmimr0 1 r/w 2 kmimr2 1 r/w 1 kmimr1 1 r/w bit initial value read/write kmimr 7 kmimr15 1 r/w 6 kmimr14 1 r/w 5 kmimr13 1 r/w 4 kmimr12 1 r/w 3 kmimr11 1 r/w 0 kmimr8 1 r/w 2 kmimr10 1 r/w 1 kmimr9 1 r/w bit initial value read/write kmimra keyboard matrix interrupt mask 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled keyboard matrix interrupt mask 0 key-sense input interrupt requests enabled 1 key-sense input interrupt requests disabled ticrr?nput capture register r h'fff2 tmrx ticrf?nput capture register f h'fff3 tmrx 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r bit initial value read/write stores tcnt value at fall of external trigger input
940 kmpcr?ort 6 mos pull-up control register h'fff2 port 6 7 km7pcr 0 r/w 6 km6pcr 0 r/w 5 km5pcr 0 r/w 4 km4pcr 0 r/w 3 km3pcr 0 r/w 0 km0pcr 0 r/w 2 km2pcr 0 r/w 1 km1pcr 0 r/w bit initial value read/write control the port 6 built-in mos input pull-ups note: kmpcr has the same address as ticrr/tcoray of tmrx/tmry. to select kmpcr, set the hie bit to 1 in syscr. idr1?nput data register 1 h'fff4 hif (xbs) idr2?nput data register 2 h'fffc hif (xbs) 7 idr7 r w 6 idr6 r w 5 idr5 r w 4 idr4 r w 3 idr3 r w 0 idr0 r w 2 idr2 r w 1 idr1 r w bit initial value slave r/w host r/w stores host data bus contents at rise of iow when cs is low odr1?utput data register 1 h'fff5 hif (xbs) odr2?utput data register 2 h'fffd hif (xbs) 7 odr7 r/w r 6 odr6 r/w r 5 odr5 r/w r 4 odr4 r/w r 3 odr3 r/w r 0 odr0 r/w r 2 odr2 r/w r 1 odr1 r/w r bit initial value slave r/w host r/w odr contents are output to the host data bus when ha0 is low, cs is low, and ior is low
941 tisr?imer input select register h'fff5 tmry 7 1 6 1 5 1 4 1 3 1 0 is 0 r/w 2 1 1 1 bit initial value read/write input select 0 1 ivg signal is selected vsynci/tmiy (tmciy/tmriy) is selected str1?tatus register 1 h'fff6 hif (xbs) str2?tatus register 2 h'fffe hif (xbs) 7 dbu 0 r/w r 6 dbu 0 r/w r 5 dbu 0 r/w r 4 dbu 0 r/w r 3 c/ d 0 r r 0 obf 0 r/(w) * r 2 dbu 0 r/w r 1 ibf 0 r r bit initial value slave r/w host r/w output buffer full 0 [clearing condition] when the host processor reads odr or the slave writes 0 in the obf bit 1 [setting condition] when the slave processor writes to odr user-defined bits input buffer full 0 [clearing condition] when the slave processor reads idr 1 [setting condition] when the host processor writes to idr command/data note: * only 0 can be written, to clear the flag. 0 contents of input data register (idr) are data 1 contents of input data register (idr) are a command
942 dadr0?/a data register 0 h'fff8 d/a converter dadr1?/a data register 1 h'fff9 d/a converter 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w bit initial value read/write stores data for d/a conversion dacr?/a control register h'fffa d/a converter 7 daoe1 0 r/w 6 daoe0 0 r/w 5 dae 0 r/w 4 1 3 1 0 1 2 1 1 1 bit initial value read/write d/a enabled daoe1 0 conversion result dae * 0 1 0 1 * 1 0 1 daoe0 0 1 channel 0 and 1 d/a conversion disabled channel 0 d/a conversion enabled channel 1 d/a conversion disabled channel 0 and 1 d/a conversion enabled channel 0 d/a conversion disabled channel 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled channel 0 and 1 d/a conversion enabled * : don? care d/a output enable 0 0 analog output da0 disabled 1 d/a conversion is enabled on channel 0. analog output da0 is enabled d/a output enable 1 0 analog output da1 disabled 1 d/a conversion is enabled on channel 1. analog output da1 is enabled
943 tconri?imer connection register i h'fffc timer connection bit initial value read/write 7 simod1 0 r/w 6 simod0 0 r/w 5 scone 0 r/w 4 icst 0 r/w 3 hfinv 0 r/w 0 viinv 0 r/w 2 vfinv 0 r/w 1 hiinv 0 r/w input synchronization mode select 1 and 0 0 1 no signal s-on-g mode composite mode separate mode 0 1 0 1 simod1 mode hfbacki input csynci input hsynci input hsynci input ihi signal vfbacki input pdc input pdc input vsynci input ivi signal simod0 synchronization signal connection enable 0 1 ftia input normal connection scone ftia ftib ftic ftid tmci1 tmri1 mode ftib input ftic input tmci1 input tmri1 input ftid input ivi signal synchronization signal connec- tion mode tmo1 signal vfbacki input ihi signal ivi inverse signal ihi signal input synchronization signal inversion 0 the vsynci pin state is used directly as the vsynci input 1 the vsynci pin state is inverted before use as the vsynci input input synchronization signal inversion 0 the hsynci and csynci pin states are used directly as the hsynci and csynci inputs 1 the hsynci and csynci pin states are inverted before use as the hsynci and csynci inputs input synchronization signal inversion 0 the vfbacki pin state is used directly as the vfbacki input 1 the vfbacki pin state is inverted before use as the vfbacki input input capture start bit 0 the ticrr and ticrf input capture functions are stopped [clearing condition] when a rising edge followed by a falling edge is detected on tmrix 1 the ticrr and ticrf input capture functions are operating (waiting for detection of a rising edge followed by a falling edge on tmrix) [setting condition] when 1 is written in icst after reading icst = 0 input synchronization signal inversion 0 the hfbacki pin state is used directly as the hfbacki input 1 the hfbacki pin state is inverted before use as the hfbacki input
944 tconro?imer connection register o h'fffd timer connection bit initial value read/write 7 hoe 0 r/w 6 voe 0 r/w 5 cloe 0 r/w 4 cboe 0 r/w 3 hoinv 0 r/w 0 cboinv 0 r/w 2 voinv 0 r/w 1 cloinv 0 r/w output synchronization signal inversion 0 the cblank signal is used directly as the cblank output 1 the cblank signal is inverted before use as the cblank output output synchronization signal inversion 0 the clo signal (cl1, cl2, cl3, or cl4 signal) is used directly as the clampo output 1 the clo signal (cl1, cl2, cl3, or cl4 signal) is inverted before use as the clampo output output synchronization signal inversion 0 the ivo signal is used directly as the vsynco output 1 the ivo signal is inverted before use as the vsynco output output synchronization signal inversion 0 the iho signal is used directly as the hsynco output 1 the iho signal is inverted before use as the hsynco output output enable 0 the p27/a15/pw15/cblank pin functions as the p27/a15/pw15 pin 1 in mode 1 (expanded mode with on-chip rom disabled): the p27/a15/pw15/cblank pin functions as the a15 pin in modes 2 and 3 (expanded modes with on-chip rom enabled): the p27/a15/pw15/cblank pin functions as the cblank pin output enable 0 the p64/ftic/ kin4 /cin4/clampo pin functions as the p64/ftic/ kin4 /cin4 pin 1 the p64/ftic/ kin4 /cin4/clampo pin functions as the clampo pin output enable 0 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the p61/ftoa/ kin1 /cin1 pin 1 the p61/ftoa/ kin1 /cin1/vsynco pin functions as the vsynco pin output enable 0 the p44/tmo1/hirq1/hsynco pin functions as the p44/tmo1/hirq1 pin 1 the p44/tmo1/hirq1/hsynco pin functions as the hsynco pin
945 tconrs?imer connection register s h'fffe timer connection 7 tmrx/y 0 r/w 6 isgene 0 r/w 5 homod1 0 r/w 4 homod0 0 r/w 3 vomod1 0 r/w 0 clmod0 0 r/w 2 vomod0 0 r/w 1 clmod1 0 r/w bit initial value read/write clamp waveform mode select 1 and 0 clmod1 clmod0 0 1 0 1 0 1 0 1 0 1 0 1 description the cl1 signal is selected the cl2 signal is selected the cl3 signal is selected the cl4 signal is selected isgene 0 1 vertical synchronization output mode select 1 and 0 vomod1 vomod0 0 1 0 1 0 1 0 1 0 1 0 1 description isgene 0 1 horizontal synchronization output mode select 1 and 0 homod1 homod0 0 1 0 1 0 1 0 1 0 1 0 1 description the ihi signal (without 2fh modification) is selected the ihi signal (with 2fh modification) is selected the cl1 signal is selected the ihg signal is selected isgene 0 1 the ivi signal (without fall modification or ihi synchronization) is selected the ivi signal (without fall modification, with ihi synchronization) is selected the ivi signal (with fall modification, without ihi synchronization) is selected the ivi signal (with fall modification and ihi synchronization) is selected the ivg signal is selected internal synchronization signal select tmrx/tmry access select 0 the tmrx registers are accessed at addresses h'fff0 to h'fff5 1 the tmry registers are accessed at addresses h'fff0 to h'fff5
946 sedgr?dge sense register h'ffff timer connection bit initial value read/write 7 vedg 0 r/(w) 6 hedg 0 r/(w) 5 cedg 0 r/(w) 4 hfedg 0 r/(w) 3 vfedg 0 r/(w) 0 ivi * 2 r 2 preqf 0 r/(w) 1 ihi * 2 r * 1 * 1 * 1 * 1 * 1 * 1 ivi signal level 0 the ivi signal is low 1 the ivi signal is high notes: 1. 2. ihi signal level 0 the ihi signal is low 1 the ihi signal is high pre-equalization flag 0 [clearing condition] when 0 is written in preqf after reading preqf = 1 1 [setting condition] when an ihi signal 2fh modification condition is detected vfbacki edge 0 [clearing condition] when 0 is written in vfedg after reading vfedg = 1 1 [setting condition] when a rising edge is detected on the vfbacki pin hfbacki edge 0 [clearing condition] when 0 is written in hfedg after reading hfedg = 1 1 [setting condition] when a rising edge is detected on the hfbacki pin csynci edge 0 [clearing condition] when 0 is written in cedg after reading cedg = 1 1 [setting condition] when a rising edge is detected on the csynci pin hsynci edge 0 [clearing condition] when 0 is written in hedg after reading hedg = 1 1 [setting condition] when a rising edge is detected on the hsynci pin vsynci edge 0 [clearing condition] when 0 is written in vedg after reading vedg = 1 1 [setting condition] when a rising edge is detected on the vsynci pin only 0 can be written, to clear the flags. the initial value is undefined since it depends on the pin states.
947 pgnocr?ort g nch-od control register h'fe16 port g 7 pg7noc 0 r/w 6 pg6noc 0 r/w 5 pg5noc 0 r/w 4 pg4noc 0 r/w 3 pg3noc 0 r/w 0 pg0noc 0 r/w 2 pg2noc 0 r/w 1 pg1noc 0 r/w bit initial value read/write specify the output driver type for pins on port g penocr?ort e nch-od control register h'fe18 port e 7 pe7noc 0 r/w 6 pe6noc 0 r/w 5 pe5noc 0 r/w 4 pe4noc 0 r/w 3 pe3noc 0 r/w 0 pe0noc 0 r/w 2 pe2noc 0 r/w 1 pe1noc 0 r/w bit initial value read/write specify the output driver type for pins on port e pfnocr?ort f nch-od control register h'fe19 port f 7 pf7noc 0 r/w 6 pf6noc 0 r/w 5 pf5noc 0 r/w 4 pf4noc 0 r/w 3 pf3noc 0 r/w 0 pf0noc 0 r/w 2 pf2noc 0 r/w 1 pf1noc 0 r/w bit initial value read/write specify the output driver type for pins on port f pcnocr?ort c nch-od control register h'fe1c port c 7 pc7noc 0 r/w 6 pc6noc 0 r/w 5 pc5noc 0 r/w 4 pc4noc 0 r/w 3 pc3noc 0 r/w 0 pc0noc 0 r/w 2 pc2noc 0 r/w 1 pc1noc 0 r/w bit initial value read/write specify the output driver type for pins on port c
948 pdnocr?ort d nch-od control register h'fe1d port d 7 pd7noc 0 r/w 6 pd6noc 0 r/w 5 pd5noc 0 r/w 4 pd4noc 0 r/w 3 pd3noc 0 r/w 0 pd1noc 0 r/w 2 pd2noc 0 r/w 1 pd1noc 0 r/w bit initial value read/write specify the output driver type for pins on port c pgodr?ort g output data register h'fe46 port g 7 pg7odr 0 r/w 6 pg6odr 0 r/w 5 pg5odr 0 r/w 4 pg4odr 0 r/w 3 pg3odr 0 r/w 0 pg0odr 0 r/w 2 pg2odr 0 r/w 1 pg1odr 0 r/w bit initial value read/write store output data for pins on port g pgpin?ort g input data register h'fe47 (r) port g 7 pg7pin * r 6 pg6pin * r 5 pg5pin * r 4 pg4pin * r 3 pg3pin * r 0 pg0pin * r 2 pg2pin * r 1 pg1pin * r bit initial value read/write return the pin state on port g note: * determined by the state of pins pg7 to pg0. pgddr?ort g data direction register h'fe47 (w) port g 7 pg7ddr 0 r/w 6 pg6ddr 0 r/w 5 pg5ddr 0 r/w 4 pg4ddr 0 r/w 3 pg3ddr 0 r/w 0 pg0ddr 0 r/w 2 pg2ddr 0 r/w 1 pg1ddr 0 r/w bit initial value read/write select input or output for the pins of port g
949 peodr?ort e output data register h'fe48 port e 7 pe7odr 0 r/w 6 pe6odr 0 r/w 5 pe5odr 0 r/w 4 pe4odr 0 r/w 3 pe3odr 0 r/w 0 pe0odr 0 r/w 2 pe2odr 0 r/w 1 pe1odr 0 r/w bit initial value read/write store output data for pins on port e pfodr?ort f output data register h'fe49 port f 7 pf7odr 0 r/w 6 pf6odr 0 r/w 5 pf5odr 0 r/w 4 pf4odr 0 r/w 3 pf3odr 0 r/w 0 pf0odr 0 r/w 2 pf2odr 0 r/w 1 pf1odr 0 r/w bit initial value read/write store output data for pins on port f pepin?ort e input data register h'fe4a (r) port e 7 pe7pin * r 6 pe6pin * r 5 pe5pin * r 4 pe4pin * r 3 pe3pin * r 0 pe0pin * r 2 pe2pin * r 1 pe1pin * r bit initial value read/write return the pin state on port e note: * determined by the state of pins pe7 to pe0. peddr?ort e data direction register h'fe4a (w) port e 7 pe7ddr 0 w 6 pe6ddr 0 w 5 pe5ddr 0 w 4 pe4ddr 0 w 3 pe3ddr 0 w 0 pe0ddr 0 w 2 pe2ddr 0 w 1 pe1ddr 0 w bit initial value read/write select input or output for the pins of port e
950 pfpin?ort f input data register h'fe4b (r) port f 7 pf7pin * r 6 pf6pin * r 5 pf5pin * r 4 pf4pin * r 3 pf3pin * r 0 pf0pin * r 2 pf2pin * r 1 pf1pin * r bit initial value read/write return the pin state on port f note: * determined by the state of pins pf7 to pf0. pfddr?ort f data direction register h'fe4b (w) port f 7 pf7ddr 0 w 6 pf6ddr 0 w 5 pf5ddr 0 w 4 pf4ddr 0 w 3 pf3ddr 0 w 0 pf0ddr 0 w 2 pf2ddr 0 w 1 pf1ddr 0 w bit initial value read/write select input or output for the pins of port f pcodr?ort c output data register h'fe4c port c 7 pc7odr 0 r/w 6 pc6odr 0 r/w 5 pc5odr 0 r/w 4 pc4odr 0 r/w 3 pc3odr 0 r/w 0 pc0odr 0 r/w 2 pc2odr 0 r/w 1 pc1odr 0 r/w bit initial value read/write store output data for pins on port c pdodr?ort d output data register h'fe4d port d 7 pd7odr 0 r/w 6 pd6odr 0 r/w 5 pd5odr 0 r/w 4 pd4odr 0 r/w 3 pd3odr 0 r/w 0 pd0odr 0 r/w 2 pd2odr 0 r/w 1 pd1odr 0 r/w bit initial value read/write store output data for pins on port d
951 pcpin?ort c input data register h'fe4e (r) port c 7 pc7pin * r 6 pc6pin * r 5 pc5pin * r 4 pc4pin * r 3 pc3pin * r 0 pc0pin * r 2 pc2pin * r 1 pc1pin * r bit initial value read/write return the pin state on port c note: * determined by the state of pins pc7 to pc0. pcddr?ort c data direction register h'fe4e (w) port c 7 pc7ddr 0 w 6 pc6ddr 0 w 5 pc5ddr 0 w 4 pc4ddr 0 w 3 pc3ddr 0 w 0 pc0ddr 0 w 2 pc2ddr 0 w 1 pc1ddr 0 w bit initial value read/write select input or output for the pins of port c pdpin?ort d input data register h'fe4f (r) port d 7 pd7pin * r 6 pd6pin * r 5 pd5pin * r 4 pd4pin * r 3 pd3pin * r 0 pd0pin * r 2 pd2pin * r 1 pd1pin * r bit initial value read/write return the pin state on port d note: * determined by the state of pins pd7 to pd0. pdddr?ort d data direction register h'fe4f (w) port d 7 pd7ddr 0 w 6 pd6ddr 0 w 5 pd5ddr 0 w 4 pd4ddr 0 w 3 pd3ddr 0 w 0 pd0ddr 0 w 2 pd2ddr 0 w 1 pd1ddr 0 w bit initial value read/write select input or output for the pins of port d
952 appendix c i/o port block diagrams c.1 port 1 block diagram r qd d p1npcr c reset r qd p1ndr c reset wp1p r q p1nddr c reset wp1d wp1 8-bit pwm internal data bus internal address bus pwm output enable pwm output p1n * rp1p rp1 mode 2, 3 mode 1 hardware standby expe wp1p wp1d wp1 rp1p rp1 n = 0 to 7 note: * set priority : write to p1pcr : write to p1ddr : write to p1ddr : read p1pcr : read port 1 mode 1 figure c.1 port 1 block diagram
953 c.2 port 2 block diagrams r qd d p2npcr c reset r qd p2ndr c reset wp2p r q p2nddr c reset wp2d wp2 8-bit pwm internal data bus internal address bus pwm output enable pwm output p2n * rp2p rp2 mode 2, 3 mode 1 hardware standby expe wp2p wp2d wp2 rp2p rp2 n = 0 to 3 note: * set priorit y : write to p2pcr : write to p2ddr : write to port 2 : read p2pcr : read port 2 mode 1 figure c.2 port 2 block diagram (pins p20 to p23)
954 r qd d p2npcr c reset r qd p2ndr c reset wp2p r q p2nddr c reset wp2d wp2 8-bit pwm internal data bus internal address bus pwm output enable pwm output p2n * rp2p rp2 mode 2, 3 mode 1 hardware standby expe iose pwm output enable wp2p wp2d wp2 rp2p rp2 n = 4 to 6 note: * set priority : write to p2pcr : write to p2ddr : write to port 2 : read p2pcr : read port 2 mode 1 figure c.3 port 2 block diagram (pins p24 to p26)
955 r qd d p27pcr c reset r qd p27dr c reset wp2p r q p27ddr c reset wp2d mode 2, 3 wp2 8-bt pwm internal data bus internal address bus pwm output enable pwm output timer connection cblank cblank output enable p27 * rp2p rp2 mode 2, 3 mode 1 hardware standby expe iose mode 1 pwm output enable wp2p wp2d wp2 rp2p rp2 note: * set priority : write to p2pcr : write to p2ddr : write to port 2 : read p2pcr : read port 2 figure c.4 port 2 block diagram (pin p27)
956 c.3 port 3 block diagram r qd d p3npcr c reset r qd p3ndr c reset wp3p r q p3nddr c reset wp3d wp3 cs iow p3n rp3p rp3 mode 2, 3 mode 1 hardware standby external address write expe hi12e lpce cs ior hif : lpc internal data bus host interface data (hif:xbs) address/data output address/data input output enable wp3p wp3d wp3 rp3p rp3 n = 0 to 3 : write to p3pcr : write to p3ddr : write to port 3 : read p3pcr : read port 3 external address read figure c.5 port 3 block diagram (pins p30 to p33)
957 r qd p3npcr c reset r qd p3ndr c reset wp3p wp3 cs iow p3n rp3p rp3 mode 2, 3 mode 1 expe hi12e lpce hif : lpc host interface bus (hif:xbs) internal data bus lrset , lframe input lclk input external address write cs ior hardware standby d r q p3nddr c reset wp3d wp3p wp3d wp3 rp3p rp3 n = 4, 5, 6 : write to p3pcr : write to p3ddr : write to port 3 : read p3pcr : read port 3 external address read figure c.6 port 3 block diagram (pins p34 to p36)
958 r qd p37pcr c reset r qd p37dr c reset wp3p wp3 cs iow p37 rp3p rp3 mode 2, 3 mode 1 expe hi12e lpce hif : lpc internal data bus host interface bus (hif:xbs) serirq output serirq input output enable hardware standby external address write cs ior d r q p37ddr c reset wp3d wp3p wp3d wp3 rp3p rp3 : write to p3pcr : write to p3ddr : write to port 3 : read p3pcr : read port 3 external address read figure c.7 port 3 block diagram (pin p37)
959 c.4 port 4 block diagrams d r qd p40dr c reset r q p40ddr c reset hardware standby wp4d wp4 sci2 internal data bus txd2/irtxd transmit enable 8-bit timer 0 counter clock input p40 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 figure c.8 port 4 block diagram (pin p40)
960 d r qd p41dr c reset r q p41ddr c reset wp4d wp4 8-bit timer 0 internal data bus 8-bit timer output output enable sci2 receive enable rxd2/irrxd p41 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 hardware standby figure c.9 port 4 block diagram (pin p41)
961 d r qd p42dr c reset r q p42ddr c reset wp4d * 1 * 2 wp4 sci2 internal data bus input enable clock output sda1 output sda1 input transmit enable output enable clock input iic1 8-bit timer 0 reset input p42 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 notes: 1. output enable signal 2. open drain control signal hardware standby figure c.10 port 4 block diagram (pin p42)
962 d r qd p43dr c reset r q p43ddr c reset wp4d wp4 host interface internal data bus resobf2 (resets hirq11) timer connection hsynci input 8-bit timer 1 counter clock input p43 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 hardware standby figure c.11 port 4 block diagram (pin p43)
963 d r qd p44dr c r q p44ddr c reset wp4d wp4 tmo1 output output enable 8-bit timer1 p44 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 reset host interface resobf1 (resets hirq1) timer connection interna data bus hsynco output output enable hardware standby figure c.12 port 4 block diagram (pin p44)
964 d r qd p45dr c reset r q p45ddr c reset wp4d wp4 host interface internal data bus resobf1 (resets hirq12) timer connection csynci input 8-bit timer1 timer reset input p45 rp4 wp4d wp4 rp4 : write to p4ddr : write to port 4 : read port 4 hardware standby figure c.13 port 4 block diagram (pin p45)
965 d r qd p4ndr c reset r q p4nddr c reset wp4d wp4 14-bit pwm internal data bus pwx0, pwx1 output output enable p4n rp4 wp4d wp4 rp4 n = 6 or 7 : write to p4ddr : write to port 4 : read port 4 hardware standby figure c.14 port 4 block diagram (pins p46, p47)
966 c.5 port 5 block diagrams d r qd p50dr c reset r q p50ddr c reset wp5d wp5 sci0 internal data bus serial transmit data output enable p50 rp5 wp5d wp5 rp5 : write to p5ddr : write to port 5 : read port 5 hardware standby figure c.15 port 5 block diagram (pin p50)
967 d r qd p51dr c reset r q p51ddr c reset wp5d wp5 sci0 internal data bus input enable serial receive data p51 rp5 wp5d wp5 rp5 : write to p5ddr : write to port 5 : read port 5 hardware standby figure c.16 port 5 block diagram (pin p51)
968 d r qd p52dr c reset r q p52ddr c reset wp5d * 1 * 2 wp5 sci0 internal data bus input enable clock output scl0 output scl0 input transmit enable output enable clock input iic0 p52 rp5 wp5d wp5 rp5 : write to p5ddr : write to port 5 : read port 5 notes: 1. output enable signal 2. open drain control si g nal hardware standby figure c.17 port 5 block diagram (pin p52)
969 c.6 port 6 block diagrams r qd d kmpcr c reset r qd p6ndr c reset wp6p r q p6nddr c reset wp6d wp6 16-bit frt internal data bus ftci input ftia input ftib input ftid input a/d converter analog input timer connection 8-bit timers y, x key-sense interrupt input kmimr0, 2, 3, 5 hfbacki input, tmix input, vsynci input, tmiy input, vfbacki input p6n rp6p rp6 hardware standby wp6p wp6d wp6 rp6p rp6 n = 0, 2, 3, 5 : write to p6pcr : write to p6ddr : write to port 6 : read p6pcr : read port 6 figure c.18 port 6 block diagram (pins p60, p62, p63, p65)
970 r qd d kmpcr c reset r qd p61dr c reset wp6p r q p61ddr c reset wp6d wp6 16-bit frt internal data bus ftoa output output enable timer connection vsynco output output enable a/d converter analog input key-sense interrupt input kmimr1 p61 rp6p rp6 hardware standby wp6p wp6d wp6 rp6p rp6 : write to p6pcr : write to p6ddr : write to port 6 : read p6pcr : read port 6 figure c.19 port 6 block diagram (pin p61)
971 r qd d kmpcr c reset r qd p64dr c reset wp6p r q p64ddr c reset wp6d wp6 timer connection internal data bus clampo output output enable a/d converter analog input 16-bit frt ftic input key-sense in terrupt input kmimr4 p64 rp6p rp6 hardware standby wp6p wp6d wp6 rp6p rp6 : write to p6pcr : write to p6ddr : write to port 6 : read p6pcr : read port 6 figure c.20 port 6 block diagram (pin p64)
972 r qd d kmpcr c reset r qd p66dr c reset wp6p r q p66ddr c reset wp6d wp6 16-bit frt internal data bus ftob output output enable a/d converter analog input irq6 input kmimr6 other key-sense interrupt inputs irq6 enable p66 rp6p rp6 hardware standby wp6p wp6d wp6 rp6p rp6 : write to p6pcr : write to p6ddr : write to port 6 : read p6pcr : read port 6 figure c.21 port 6 block diagram (pin p66)
973 r qd d kmpcr c reset r qd p67dr c reset wp6p r q p67ddr c reset wp6d wp6 8-bit timer x internal data bus tmox output output enable a/d converter analog input irq7 input kmimr7 other key-sense interrupt inputs and waleup event interrupt input irq7 enable p67 rp6p rp6 hardware standby wp6p wp6d wp6 rp6p rp6 : write to p6pcr : write to p6ddr : write to port 6 : read p6pcr : read port 6 figure c.22 port 6 block diagram (pin p67)
974 c.7 port 7 block diagrams a/d converter internal data bus analog input p7n rp7 n = 0 to 5 : read port 7 rp7 figure c.23 port 7 block diagram (pins p70 to p75) a/d converter internal data bus analog input d/a converter output enable analog output p7n rp7 n = 6 or 7 : read port 7 rp7 figure c.24 port 7 block diagram (pins p76, p77)
975 c.8 port 8 block diagrams d r qd p80dr c reset r q p80ddr c reset internal data bus hi12e expe mode 2, 3 wp8d wp8 hif : xbs ha0 input hif : lpc pme output pme input output enable p80 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 hardware standby * 1 * 2 notes: 1. output enable signal 2. open drain control si g nal figure c.25 port 8 block diagram (pin p80)
976 d r qd p81dr c reset r q p81ddr c reset wp8d mode 2, 3 expe cs2e hi12e wp8 hif : xbs cs2 input hif : lpc ga20 input hif : xbs internal data bus ga20 output output enable hif : lpc ga20 output output enable p81 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 * 1 * 2 notes: 1. output enable signal 2. open drain control signal hardware standby figure c.26 port 8 block diagram (pin p81)
977 d r qd p82dr c reset r q p82ddr c reset wp8d wp8 p82 rp8 hif : xbs hifsd input hif : lpc internal data bus clkrun output output enable clkrun input hardware standby mode 2, 3 expe lpce hi12e sde * 1 * 2 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 notes: 1. output enable signal 2. open drain control si g nal figure c.27 port 8 block diagram (pin p82)
978 d r qd p83dr c reset r q p83ddr c reset internal data bus wp8d wp8 p83 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 hif : lpc lpcpd input hardware standby figure c.28 port 8 block diagram (pin p83)
979 d r qd p84dr c reset r q p84ddr c reset wp8d wp8 sci1 internal data bus txd1 transmit enable irq3 input irq3 enable p84 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 hardware standby figure c.29 port 8 block diagram (pin p84)
980 d r qd p85dr c reset r q p85ddr c reset wp8d wp8 sci1 internal data bus input enable serial receive data irq4 input irq4 enable p85 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 hardware standby figure c.30 port 8 block diagram (pin p85)
981 d r qd p86dr c reset r q p86ddr c reset wp8d * 1 * 2 wp8 sci1 internal data bus input enable clock output scl1 output scl1 input irq5 input irq5 enable transmit enable output enable clock input iic1 p86 rp8 wp8d wp8 rp8 : write to p8ddr : write to port 8 : read port 8 notes: 1. output enable signal 2. open drain control hardware standby figure c.31 port 8 block diagram (pin p86)
982 c.9 port 9 block diagrams d r qd p90dr c reset r q p90ddr c reset wp9d mode 2, 3 expe expe abw fga20e hi12e cs2e wp9 hif : xbs ecs2 input a/d converter external trigger input bus controller internal data bus lwr output p90 rp9 wp9d wp9 rp9 : write to p9ddr : write to port 9 : read port 9 irq2 input irq2 enable hardware standby figure c.32 port 9 block diagram (pin p90)
983 d r qd p9ndr c reset r q p9nddr c reset internal data bus wp9d wp9 irq1 input irq0 input irq1 enable irq0 enable p9n rp9 wp9d wp9 rp9 n = 1 or 2 : p9ddr : write to port 9 : read port 9 hardware standby figure c.33 port 9 block diagram (pins p91, p92)
984 d r qd p9ndr c reset r q p9nddr c reset wp9d mode 2, 3 expe expe hi12e wp9 bus controller internal data bus rd output hwr output as/ios output hif : xbs ior input iow input cs1 input p9n rp9 wp9d wp9 rp9 n = 3 to 5 : write to p9ddr : write to port 9 : read port 9 mode 2, 3 expe hi12e hardware standby figure c.34 port 9 block diagram (pins p93 to p95)
985 d r s q p96ddr c reset mode 1 wp9d subclock input f output internal data bus subclock input enable hardware standby p96 wp9d rp9 : write to p9ddr : read port 9 rp9 figure c.35 port 9 block diagram (pin p96)
986 d r qd p97dr c reset r q p97ddr c reset wp9d expe wp9 iic0 sda0 input sda0 output transmit enable bus controller internal data bus input enable wait input p97 rp9 wp9d wp9 rp9 : write to p9ddr : write to port 9 : read port 9 * 1 * 2 notes: 1. output enable signal 2. open drain control signal hardware standby figure c.36 port 9 block diagram (pin p97)
987 c.10 port a block diagrams d r qd panodr c reset r q panddr c reset mode 2 iose expe wpad wpa rpao rpa a/d converter analog input key-sense interrupt input internal data bus internal address bus kmimr n+8 pan hardware standby wpad wpa rpao rpa n = 0 or 1 : write to paddr : write to paodr : read paodr : read port a figure c.37 port a block diagram (pins pa0, pa1)
988 d r qd panodr c reset r q panddr c reset wpad wpa rpao rpa a/d converter analog input key-sense interrupt input kmimr n+8 pan hardware standby wpad wpa rpao rpa n = 2 or 3 : write to paddr : write to paodr : read paodr : read port a * 1 * 2 keyboard buffer controller internal data bus internal address bus output enable output input notes: 1. output enable signal 2. open-drain control signal mode 2 iose expe figure c.38 port a block diagram (pins pa2, pa3)
989 d r qd panodr c reset r q panddr c reset iics wpad wpa rpao rpa a/d converter input analog input key-sense interrupt input kmimr n+8 pan hardware standby wpad wpa rpao rpa n = 4 to 7 : write to paddr : write to paodr : read paodr : read port a * 1 * 2 keyboard buffer controller internal data bus internal address bus output enable output notes: 1. output enable signal 2. open-drain control signal mode 2 iose expe figure c.39 port a block diagram (pins pa4 to pa7)
990 c.11 port b block diagram d r qd pbnodr c reset hif : xbs (d0, d1) (d0, d1) r q pbnddr c reset internal data bus expe external address write abw wpbd resobf3, 4 (reset hirq3, hirq4) wpb external address read rpbo rpb pbn mode 2, 3 expe hif : lpc lsmi , lsci output lsmi , lsci input output enable wuemrn wakeup event interrupt input hardware standby * 1 * 2 wpbd wpb rpbo rpb n = 0, 1 : write to pbddr : write to pbodr : read pbodr : read port b notes: 1. output enable signal 2. open drain control signal figure c.40 port b block diagram (pins pb0 and pb1)
991 d r qd pbnodr c reset (d2, d3) (d2, d3) r q pbnddr c reset internal data bus expe external address write abw wpbd wpb hif : xbs wuemrn cs3 input cs4 input external address read rpbo rpb pbn wpbd wpb rpbo rpb n = 2, 3 : write to pbddr : write to pbodr : read pbodr : read port b hardware standby wakeup event interrupt input mode 2, 3 cs input enable expe figure c.41 port b block diagram (pins pb2 and pb3)
992 d r qd pbnodr c reset (d7 to d4) (d7 to d4) r q pbnddr c reset internal data bus expe external address write abw wpbd wpb external address read rpbo rpb pbn wpbd wpb rpbo rpb n = 4 to 7 : write to pbddr : write to pbodr : read pbodr : read port b wuemrn wakeup event interrupt hardware standby figure c.42 port b block diagram (pins pb4 to pb7)
993 c.12 port c, d, e, f, g block diagram d r qd pxnodr c reset pmos enable r q pxnnoc c reset internal data bus wpxn wpx r qd pxnddr c reset wpxd rpxo rpx pxn wpxn wpxd wpx rpxo rpx x = c, d, e, f, g n = 0 to 7 : write to pxnocr : write to pxddr : write to pxodr : read pxodr : read port x hardware standby figure c.43 port c, d, e, f, g block diagram
994 appendix d pin states d.1 port states in each processing state table d.1 i/o port states in each processing state port name pin name mcu operating mode reset hardware standby mode software standby mode watch mode sleep mode sub- sleep mode subactive mode program execution state port 1 1 l t kept * kept * kept * kept * a7 to a0 a7 to a0 a7 to a0 2, 3 (expe = 1) t address output/ input port address output/ input port 2, 3 (expe = 0) i/o port i/o port port 2 1 l t kept * kept * kept * kept * a15 to a8 a15 to a8 a15 to a8 2, 3 (expe = 1) t address output/ input port address output/ input port 2, 3 (expe = 0) i/o port i/o port port 3 1 t t t t t t d15 to d8 d15 to d8 d15 to d8 2, 3 (expe = 1) 2, 3 (expe = 0) kept kept kept kept i/o port i/o port port 4 1 t t kept kept kept kept i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 5 1 t t kept kept kept kept i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 6 1 t t kept kept kept kept i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 7 1 t t t t t t input port input port 2, 3 (expe = 1) 2, 3 (expe = 0) port 8 1 t t kept kept kept kept i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 97 1 t t t/kept t/kept t/kept t/kept wait / wait / wait 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) kept kept kept kept i/o port i/o port
995 port name pin name mcu operating mode reset hardware standby mode software standby mode watch mode sleep mode sub- sleep mode subactive mode program execution state port 96 excl 1 clock output t [ddr = 1] h [ddr = 0] t excl input [ddr = 1] clock output excl input excl input clock output/ excl input/ input port 2, 3 (expe = 1) t [ddr = 0] t 2, 3 (expe = 0) ports 95 to 93 1 h t h h h h as , hwr , as , hwr , as , hwr , 2, 3 (expe = 1) t rd rd rd 2, 3 (expe = 0) kept kept kept kept i/o port i/o port ports 92 to 91 1 t t kept kept kept kept i/o port i/o port 2, 3 (expe = 1) 2, 3 (expe = 0) port 90 1 t t h/kept h/kept h/kept h/kept lwr / lwr / lwr 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) kept kept kept kept i/o port i/o port port a 1 t t kept * kept * kept * kept * i/o port i/o port a23 to a16 2, 3 (expe = 1) a23 to a16/ i/o port a23 to a16/ i/o port 2, 3 (expe = 0) i/o port i/o port port b 1 t t t/kept t/kept t/kept t/kept d7 to d0/ d7 to d0/ d7 to d0 2, 3 (expe = 1) i/o port i/o port 2, 3 (expe = 0) kept kept kept kept i/o port i/o port ports c to g 1 t t kept kept kept kept i/o port i/o port (h8s/2169) 2, 3 (expe = 1) 2, 3 (expe = 0) legend: h: high l: low t: high-impedance state kept: input ports are in the high-impedance state (when ddr = 0 and pcr = 1, mos input pull- ups remain on). output ports maintain their previous state. depending on the pins, the on-chip supporting modules may be initialized and the i/o port function determined by ddr and dr used. ddr: data direction register note: * in the case of address output, the last address accessed is retained.
996 appendix e timing of transition to and recovery from hardware standby mode e.1 timing of transition to hardware standby mode (1) to retain ram contents with the rame bit set to 1 in syscr, drive the res signal low 10 system clock cycles before the stby signal goes low, as shown in figure e.1. res must remain low until stby signal goes low (minimum delay from stby low to res high: 0 ns). stby res t 2 ? 0 ns t 1 10t cyc figure e.1 timing of transition to hardware standby mode (2) to retain ram contents with the rame bit cleared to 0 in syscr, or when ram contents do not need to be retained, res does not have to be driven low as in (1). e.2 timing of recovery from hardware standby mode drive the res signal low at least 100 ns before stby goes high to execute a reset. stby res t osc1 t 100 ns figure e.2 timing of recovery from hardware standby mode
997 appendix f product codes table f.1 product codes product type product code mark code package (hitachi package code) notes h8s/2149 f-ztat version hd64f2149yv 64f2149yvfa10 100-pin plastic qfp (fp-100b) 64f2149yvte10 100-pin plastic tqfp (tfp-100b) h8s/2169 f-ztat version hd64f2169yv 64f2169yvte10 144-pin plastic tqfp (tfp-144)
998 appendix g package dimensions figures g.1 and g.2 show the package dimensions of the h8s/2149. figure g.3 shows the package dimensions of the h8s/2169. hitachi code jedec eiaj mass (reference value) fp-100b conforms 1.2 g unit: mm *dimension including the plating thickness base material dimension 0.10 16.0 0.3 1.0 0.5 0.2 16.0 0.3 3.05 max 75 51 50 26 1 25 76 100 14 0 ?8 0.5 0.08 m *0.22 0.05 2.70 *0.17 0.05 0.12 +0.13 ?.12 1.0 0.20 0.04 0.15 0.04 figure g.1 package dimensions (fp-100b)
999 hitachi code jedec eiaj mass (reference value) tfp-100b conforms 0.5 g unit: mm *dimension including the plating thickness base material dimension 16.0 0.2 14 0.08 0.10 0.5 0.1 16.0 0.2 0.5 0.10 0.10 1.20 max *0.17 0.05 0 ?8 75 51 125 76 100 26 50 m *0.22 0.05 1.0 1.00 1.0 0.20 0.04 0.15 0.04 figure g.2 package dimensions (tfp-100b)
1000 hitachi code jedec eiaj mass (reference value) tfp-144 conforms 0.6 g unit: mm *dimension including the plating thickness base material dimension 108 73 136 0 ?8 0.08 0.07 m 18.0 0.2 72 144 109 37 18.0 0.2 *0.18 0.05 0.4 1.20 max 1.0 0.5 0.1 16 1.00 0.10 0.05 *0.17 0.05 0.16 0.04 0.15 0.04 1.0 figure g.3 package dimensions (tfp-144)
h8s/2169f-ztat tm h8s/2149f-ztat tm hardware manual publication date: 1st edition, july 1999 2nd edition, february 2001 published by: electronic devices sales & marketing group semiconductor & integrated circuits hitachi, ltd. edited by: technical documentation group hitachi kodaira semiconductor co., ltd. copyright ?hitachi, ltd., 1999. all rights reserved. printed in japan.


▲Up To Search▲   

 
Price & Availability of H8S2149F-ZTAT

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X